Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Default Button < Table of Contents 3 | Images Subfolder >
Back to Default Button    Comments List
Upload Images   Link   Email  
A VBA example
Thomas Gonder 
       
13 months ago
I've set up most of my forms for previewing when first opening. Permissions allow a user to edit or not. I've found that most new users like to just cruise through the records at first (seasoned users go right to the search form). I have a Next button to do that. It's set as the default, so that after opening a form, just press enter and preview to your heart's content.

You can't see it in the next image, because the minute I take an image, the Next loses focus, but in the live version you would see the command button surrounded by little black dots.
Thomas Gonder OP 
       
13 months ago

Thomas Gonder OP 
       
13 months ago
The code snippent below appears quite complicated, but it's just testing if a control is on the form, if the user has permissions, activates it and sets the focus. For the focus line, look for the orange bit. Just name the control and add .SetFocus. This code runs in the Private Sub Form_Current() procedure of the form. The crazy name for the control is how I handle the multi-language and helps for the form.
Thomas Gonder OP 
       
13 months ago

Richard Rost 
          
13 months ago
Cool. Thanks for sharing!
Thomas Gonder OP 
       
13 months ago
A final note: I've used .SetFocus a lot, and had a lot of problems within VBA code using it. It tends to throw a lot of different RTEs. Sometimes in a way that isn't very consistent. As with other similar RTEs, I suspect the run-time of VBA ties itself up into a knot and sh!ts itself. On my to-do list is "write a procedure for doing .SetFocus" so that my .accde doesn't just die an ignoble death (even though it ran hundreds of times before without a problem). It seems crazy to have to write new procedures or a bunch of On Error Goto in lots of procedures, but that's what I'm having to do with all the odd RTEs.
Richard Rost 
          
13 months ago
I agree. Moving focus around a form is a good way to throw weird random errors. I try to avoid it if possible.

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

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/26/2025 1:28:51 PM. PLT: 1s