Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Set Focus on Form control
Richard Pitassy 
       
3 years ago
I have a Main Menu form with a number of buttons that take the user to other forms and reports ("targets").  In most cases, the Main Menu remains open behind the Target.
When the user closes the Target, I want the focus to return to a Search text box on the Main Menu.  I would like to avoid having to add code to the Close buttons on each Target to explicitly set the focus to the Main Menu search box or requery the Menu, etc.
On the Main Menu, I have tried to set the On Got Focus and  On Current events to set the focus on the Search text box but that doesn't work.  
Seems to me that when the Main Menu becomes the only open form there must be an event/property/code that can be used to set the focus on my Search box control.  Any ideas greatly appreciated.  Thanks.
Kevin Yip  @Reply  
     
3 years ago
A form's GotFocus event doesn't run if the form has controls on it.  It only runs if the form has no controls (blank form).  This may sound puzzling, but can be easily demonstrated.  Click on a textbox, then click on a blank part of the form.  You see the cursor is still inside the textbox.  The textbox doesn't lose focus (by design) if you click on the form.  That's why the form can't get focus if it has controls on it.

Regarding your original goal, I suggest you make an invisible form with a timer that checks if the main menu is the only form open ( Forms.Count = 1 And Forms(0).Name = "MainMenuForm" ).  If so, set focus accordingly.
Richard Pitassy OP  @Reply  
       
3 years ago
Thanks Kevin.  I'll give that a try.

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: 5/2/2026 2:07:38 AM. PLT: 1s