<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, February 13, 2009

ControlTip Text and Time Delay

Most of the Controls on a Form like Command Buttons, Labels, Text-Boxes and others have the Property ControlTip Text. This can be set with a Value of up to a maximum length of 255 characters, either manually during design time or through Visual Basic. The text is displayed when the Mouse Pointer rests on the Control for a few seconds. This is useful to inform the User to do certain action, like Click or Double-Click, on the Control to run a Program or Macro attached to it.


The Toolbar Buttons above also have this feature programmed with the Screen Tip Property Value (another name for ControlTip Text) to give clues to the User as to what the control does or what to do to use it. For example when you point the Mouse pointer on the Copy Toolbar Button it will show Copy (Ctrl+C) indicating that either Click on the Button to Copy the selected Text/Control or use Ctrl+C to get the same result.


The time delay is programmed into this action assuming that the Mouse Pointer rests on the Control because the user probably doesn't know what it does and needs some help to indicate what he/she should do to use it or what result one can get by using it.


Here, we will concentrate on Controls on a Main Switchboard (Control Screen), like Command Buttons, List-Boxes and how to achieve the same result without the time delay that needs for the ControlTip Text Property.


There is another Property named Tag placed near to the ControlTip Property; its function is not clearly defined and free to use, as you wish. The value in this Property will not affect the Control in any way and will not have any side effects to other Properties either. You can write a short story into the Tag Property, if you can limit your story to 2048 characters.


We are going to use this Property of different Controls on the Main Switchboard of a sample database to give clues to the User instantly what each control does or what to do (like Click or Double-Click) to run the Program or Macro attached to them.


You must select each control and display their Property Sheet(View - -> Properties) and type the Value, you would like to display, into the Tag Property. This text will appear instantly in the Label with dark background (you can use any color you like) placed at the bottom of the Form when the Mouse is moved over a Control with Tag value set and programmed.

An image of a sample Main SwitchBoard with the above trick is given below:


Sample Main SwitchBoard Image


A Label with dark background (let us call it LBLTIP) is placed at the bottom of the design to display the clues when the Mouse moves over the controls above. The example text displayed on the image is attached to the Tag Property of the List-Box with Forms' Names.


To display the clue and to remove it when the Mouse moves out of the Control we need to run few lines of VBA Code at two places. On Mouse Move Event Procedure of the Control as well as at the Detail Section of the Form to remove the text and replace it with some general message text.


The sample Code in the On Mouse Move Event Procedure of the Reports Command Button is given below that displays: Open Report SwitchBoard in the LBLTIP label below, when the Mouse is moved over the Command Button.



Private Sub cmdRpt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.LBLTIP.Caption <> Me.cmdRpt.Tag Then
Me.LBLTIP.Caption = Me.cmdRpt.Tag
End If
End Sub


When the Mouse moves out of the Command Button and touches the empty area of the Detail Section of the Form the LBLTIP Caption changes to Welcome User: Admin (the current MS-Access User Account name) appears and stays there till the mouse moves over another Control on the Form.

The VBA Code in the Detail Section On Mouse Move Event Procedure is given below:



Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strtag As String
strtag = "Welcom User: " & CurrentUser
If Me.LBLTIP.Caption <> strtag Then
Me.LBLTIP.Caption = strtag
End If
End Sub


Even though the Detail Section Mouse Move Event Procedure Code has no change; repeating all three lines of code for each control is excess work. The IF…Then statement is used to test and prevent setting the LBLTIP Caption value repeatedly.


We can implement this with a single line of code, if we write a common routine and place it in a Global Module (standard Module) and call it with a single line of code with necessary Parameters. Such a Function is given below


Copy the following VBA Code and save it in a Standard Module:



Public Function ControlTip(ByVal frmName As String, Optional strtext As String = "Welcome User: ", Optional xswitch As Integer = 0)
On Error GoTo ControlTip_Err
With Forms(frmName).Controls("lblTip")
Select Case xswitch
Case 1
If .Caption <> strtext Then
.Caption = strtext
End If
Case Else
If .Caption <> strtext Then
.Caption = strtext & CurrentUser
End If
End Select
End With

ControlTip_Exit:
Exit Function

ControlTip_Err:
MsgBox Err.Description, , "ControlTip()"
Resume ControlTip_Exit
End Function


The above Function has three Parameters:


  1. Name of the Form from where the Function is called.

  2. The LBLTIP.Caption text to display. This will be taken from the Tag Property Value of the Control. This parameter is defined as Optional so that this can be called without a value at Form-level (in our example from Detail Section) to display the welcome message after removing the earlier contents.

  3. The Optional xswitch parameter is used for display control. Value of 1 will display the Text value passed through the Second Parameter or else it will display a welcome message to the active User replacing earlier text in the LBLTIP control.



With the above Function we can simplify the first two Sub-Routines as given below:



Private Sub cmdRpt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
ControlTip Me.Name, Me. cmdRpt.Tag, 1
End Sub



Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
ControlTip Me.Name
End Sub


You can download the sample database (Access2000 Version) from the Link below and try it out.





Download - File: ControlTip2K.zip (Size:82.4K)






StumbleUpon Toolbar



Data Editing and Security Issues
Event Trapping & Summary on Datasheet
Sum() Min() Max() ParamArray
Text Box and Label Inner Margins
Multiple Parameters for Query

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