<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F&amp;blogLocale=en_US&amp;homepageUrl=http%3A%2F%2Fwww.msaccesstips.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>
www.msaccesstips.com

LEARN MS-ACCESS TIPS AND TRICKS


International Response Fund

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, September 04, 2009

Office Assistant And Msgbox Menus-3



After going through the earlier Articles on this subject I hope that the Readers are now familiar with programming the Balloon Object of Microsoft Office Assistant. You have seen that you can use this feature with few lines of customizable VBA Code to display MsgBox text formatted with Color, underline and with your favorite Images on them. We can display Menus on them to obtain responses from Users, besides the buttons that we normally use like OK, Cancel, Yes, No etc.


Since, this Article is the third part of this series I suggest that new Readers may go through the earlier Documents on this subject to learn interesting and simple ways to use this feature in MS-Access before continuing with this Article. Links to those Articles are given below:




Last week we have learned how to display Clickable Menu Options in Message Box with the use of Office Assistant. The Image of that example is given below.



MsgBox Image with Options


We have displayed the Menu Options on Message Box with the Labels Property of the Balloon Object of Office Assistant.


Here, we will learn how to display Menu Options with Checkboxes and how responses from the User can be obtained, examined and execute actions that is programmed for each choice made? The example Code and the sample image of MsgBox that displays the Check-Box Menu are given below:



Public Function ChoicesCheckBox()
Dim i As Long, msg As String
Dim bln As Balloon, j As Integer
Dim selected As Integer, checked As Integer

Set bln = Assistant.NewBalloon
With bln
.Heading = "Select Data Output Option"
.Checkboxes(1).text = "Print Preview."
.Checkboxes(2).text = "Export to Excel."
.Checkboxes(3).text = "Datasheet View."
.Button = msoButtonSetOkCancel
.text = "Select one of " _
& .Checkboxes.Count & " Choices?"
i = .Show

selected = 0
If i = msoBalloonButtonOK Then
'Validate Selection
For j = 1 To 3
If .Checkboxes(j).checked = True Then
selected = selected + 1
checked = j
End If
Next

'If User selected more than one item
'then re-run this program and force the
'User to select only one item as suggested
‘in the message text.
If selected = 0 or selected > 1 Then
Call ChoicesCheckBox
Else
Select Case checked
Case 1
Debug.Print .Checkboxes(checked).text
Case 2
Debug.Print .Checkboxes(checked).text
Case 3
Debug.Print .Checkboxes(checked).text
End Select
End If
End If
End With

End Function


Image of MsgBox with Labels Property

Like the Labels Property Array the dimension of CheckBoxes also can be up to a maximum of five elements only.


In our earlier example we have not used the OK or Cancel buttons along with the Labels based Menu because the Balloon Button (msoBalloonTypeButtons) based options were clickable and accepts the clicked item as a valid response and dismisses the Office Assistant on this action. The clicked item's index number is returned as the response value and it was easy to check this value and execute the action accordingly.

But in the case of Check-Boxes this is little more complex because of the following reasons

  1. The Check Boxes can be either in checked or in unchecked state, which needs to be validated.

  2. The User may put check-marks on one or more Options at the same time. If this cannot be allowed then there must be a validation check and force the User to make selection of one item only.

  3. If the User has the option of selecting more than one item then program must be written to execute more than one action based on the combination of selections made.

  4. In either case we have to inspect the checked or un-checked state of each element of the CheckBoxes Array to determine the validity of Menu selection.


In the example code given above the User can select only one item at a time.

  • In the validation check stage of the code, first we are checking whether the User has clicked the OK Button or not.


  • If she did then in the next step we take a count of all check-marked items, in the Variable selected.


  • If the value in Variable selected is zero (User clicked OK Button without selecting any option from the list) or selected more than one item then the Program is called again from within the ChoicesCheckBox() Function itself. This will refresh the Menu, removes the check marks and display it again. This will force the User to make only one selection as suggested in the message or she can click Cancel Button.


  • In the next step the action is programmed based on the selection made by the User.


  • If the User is allowed to put check-marks on more than one item (depending on the purpose of the Message Box based Menu) then the validation check and the execution of actions can be different and the code must be written accordingly.



The methods which I have introduced to you and explained in these three Articles are good to learn the basics of this feature and easy to understand the usage of different Properties of Balloon Object of Office Assistant.


But, you will appreciate the fact that duplicating and customizing these Codes everywhere in your Programs for different needs is not advisable. This will increase the size of your database, no flexibility in usage of Code and it is not good programming practice either.


You may go through the Articles (links given below) published earlier on this Subject that shows how to define Public Functions like MsgOK(), MsgYN(), MsgOKCL() and others with the use of Office Assistant. It simplifies the usage of this feature, without duplicating the Code, and can use them freely anywhere in your Programs like MS-Access MsgBox() Function.


The above Function Names themselves suggests what kind of Buttons will appear in the Message Box when they are called with the minimum Parameter Value of Message Text alone or Message Text and Title Values.


  1. Message Box with Office Assistant

  2. Message Box with Options Menu

  3. Office Assistant with CheckBox Menu


A comparison of the above User Defined Function usage with the MsgBox is given below for references. The underscore character in the text indicates the continuation of lines and should not be used when all values are placed on the same line.


MS-Access MsgBox() usage
Office Assistant based User Defined Function usage
MsgBox "Welcome to Tips and Tricks"MsgOK "Welcome to Tips and Tricks"
X = MsgBox("Shut Down Application", _ vbQuestion+vbDefaultButton2+vbYesNo, _ "cmdClose_Click()")X = MsgYN("Shut Down Application", _ "cmdClose_Click()")
X = MsgBox( "Click OK to Proceed or Cancel?", _ vbOKCancel+vbDefaultButton2+vbQuestion, _ "MonthEndProcess()")X = MsgOKCL("Click OK to Proceed or Cancel?", _
"MonthEndProcess()")



StumbleUpon Toolbar



Network and Report Page Setup-3
Network and Report Page Setup-2
Network and Report Page Setup
Filter by Character and Sort
Animating Label on Search Success

Labels:

0 Comments:

Post a Comment

Note:Comments subject to Review by Blog Author before displaying.

Links to this post:

Create a Link

<< Home


Creative Commons License
Learn MS-Access Tips and Tricks by msaccesstips.com is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.



This Page is best viewed with 1280 x 1024 Resolution

   FEATURED LINKS
SITEMAP
Command Button Animation
3D Headings on Forms
MsgBox & Office Assistant
Reminder Ticker
MS-Access & E-Mails
Automated E-Mail Alerts
MsgBox with Options Menu
Colorful Command Buttons
Configure Lotus Notes
Alerts through Network
Running this site has become a costly affair as the revenue from Ads is not sufficient to support it. If you find these pages informative & useful and would like to extend a helping hand, then please do it here.





Link Back to us with this Button

Learn MS-Access

Copy and Paste this HTML Code in your Webpage


Add to Technorati Favorites

Programming Blogs - Blog Catalog Blog Directory
Powered by FeedBurner
Add to Google

Software
Computers blogs
TopOfBlogs




AddMe - Search Engine Optimization Submit Your Site Free!
Go BlogZ Ave Blogs
eBlogzilla Changing LINKS
LS Blogs Blogarama
blog search directory BlogUniverse
Find Blogs in Directory RSS Directory
blogskinny.com ShowcaseBlogs.com
Amfibi

Search Engine Optimization and SEO Tools
Dmegs Web Directory Takeaway for Sale Businesses For Sale
Free Submission Directory Free site submission

Free Listing
 





Free Page Rank Checker

AddThis Social Bookmark Button

Enter your email address:

Delivered by FeedBurner



Top Blogs


Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.

My Photo
Name: Ramachandran Pillai
Location: Cochin, India

I am not an Access Guru and not through MS-Access yet. More to learn and I don’t think that aspect has any end because others have their own style of using this tool. We can learn lot more tricks, other than what we already know, from others too. My programming skills in COBOL, BASIC, Turbo-C, dBase, FoxPro, Visual Basic & Basic HTML attained through self-learning. I wrote my first COBOL Program in 1975 for ICL1901, 3rd Generation Main Frame Computer. Worked as a Computer Operator (NCR VRX8555 Mainframe Machine upto 1990) with M/s. Y.B.A. Kanoo, Saudi Arabia. Started using MS-Access Ver.2 in 1996, when dBase III+ and Foxbase (later version Foxpro) were my favorite DBMS. During Last 13 Year period I have developed more than 45 In-House Applications (medium & small) under MS-Access for our Organization, a leading Automotive Company in Oman. All the Applications are fully Secured and runs under Windows Network. It is my pleasure to share my experience with others. Anything interesting that you would like to share with me, please do. My E-mail Address: aprpillai@msaccesstips.com


If you need a Demo of any of the Topic explained here, send me an E-mail to: aprpillai@msaccesstips.com
with the Topic Description, I shall try to send a sample database to you.


Access Tips | Email | Reports | Report Tricks | Graphs | Forms | Menus | Animation | Security | Internet | How TOs | Linking | Query | Progress Meter | Alerts | Process Tips | Access Functions |




Site Designed by:www.msaccesstips.com