Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Pseudo data in a control
Mubeezi Micah 

16 years ago
Dear Richard,

I wanted to give a user an experience of how i see form controls in design view. Basically in design view, there is a visible text say "Unbound" inside the control. When you click inside the control, it disappears and reappears when you click somewhere else. I wanted to use this kind of idea to guide the user on what kind of data they should enter in addition to the control tip text property. I managed to achieve it but i found the procedure long. It would be laborious to use a similar approach for all the controls on a form. See below what i did.

First, my form name is called SelectTimePeriodF and the control names are StartDate and EndDate

When the form loads, i made the colour of the control lighter relative to other controls
Private Sub Form_Load()
   'Make the colour light grey
    StartDate.ForeColor = 12763847
    EndDate.ForeColor = 12763847
End Sub

Then when the user clicks in the control, if the current date in the control is the default date, then it should "disappear" to allow him enter a new date
Private Sub StartDate_Click()
    'Clear the default date
    If StartDate = #7/15/2005# Then
    StartDate = Null
    End If
End Sub

After the user has entered his desired date, then i change the colour back to resemble the colours of other controls

Private Sub StartDate_AfterUpdate()
    StartDate.ForeColor = 0
End Sub

However, if the user does not insert a date after clicking inside the control, i want to have the default value date back inside the control and set the colour of the control to resemble other form controls.
Private Sub StartDate_LostFocus()
    If IsNull(StartDate) Then
    StartDate = #7/15/2005#
    StartDate.ForeColor = 0
    End If
End Sub

I did the same thing for the EndDate control.

QUESTION IS: Is there a shorter way to do what i did above? By the way, also notice that although my laptop regional settings are dd/mm/yyyy, in the VBA code window, i had to enter dates as mm/dd/yyyy in order to see the date as 15/07/2005. Why is this so?

Thank you.


Thank you for clarifying,

MICAH




Reply from Richard Rost:

I really can't think of an easier way to do this than what you've already done. You'll need events in each of your controls. As far as the dates go, do you have separate input masks or formats on your table or form? That will override the regional settings in Windows.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/31/2026 7:56:34 PM. PLT: 1s