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 Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Tab Out of a Subform Back to Main Form
David Torrey de Frescheville 
     
16 months ago
I set up a tab order on a form with multiple subforms. tabbing into a subform is fine (I only have relational combo box connected to a junction table in the subforms). I cannot tab out of the subform back to the main form. Many videos on subforms don't mention this and multiple Google searches and Chat GPT suggested I use Me.Parent.SetFocus, but they don't specify which objects properties, nor which Event, I code this into Code Builder from.  I did try the subforms properties and the Lost_Focus event and the combo boxes Lost_Focus and On_Exit Events. Didn't work. I have spent hours on this. Can anyone help?  Thank you!
David Torrey de Frescheville OP  @Reply  
     
16 months ago
So, I got this code now:

Private Sub GrowthFormCOMBO_KeyDown(KeyCode As Integer, Shift As Integer)
  
    If KeyCode = 9 Then    
        Parent!HeightFromTEXTBOX.SetFocus
    End If
    
End Sub

This absolutely gets me out of the sub form and back to the main form, but instead of putting the focus on the textbox specified, the focus jumps to the next textbox after that. How do I correct this?  THANK YOU!
Joe Holland  @Reply  
      
16 months ago
I use a GoToControl command in the On Exit property on the last field in the subform to get back to the main form.
Joe Holland  @Reply  
      
16 months ago
Check what is in the text box you are sending it to. Maybe an event is triggering.
David Torrey de Frescheville OP  @Reply  
     
16 months ago
Hi Joe - Thanks for answering my post. What would that code look like for the GoToControl? I’m pretty new at coding in VB. Thanks!
Kevin Robertson  @Reply  
          
16 months ago
David Torrey de Frescheville OP  @Reply  
     
16 months ago
Thank you for your help guys. Ok. So I tried the GoToControl. If I do the GoToControl from the "On Exit" event, it does nothing. The cursor stays in the last field in the subform. If I do the GoToCotrol from the KeyDown event, it gets me out of the subform, but agin, it gets me right to the second control after the subform instead of the one I specified. I checked the name multiple times. It's basically doing the sane thing the set focus is doing. Any ideas?
David Torrey de Frescheville OP  @Reply  
     
16 months ago
Oh boy do I feel dumb. I just realized Kevin you posted a link! Im watching that video now. THANK YOU!!!!
David Torrey de Frescheville OP  @Reply  
     
16 months ago
I watched Richards videos on both SetFocus and GoToControl.  I followed the instructions and did DoCmd.GoToControl.OpenForm "PlantsDatabaseF" and then DoCmd.GoToControl "PlantsFromHeightTXTBOX" and it did the same thing as before. it moved from the subform to the parent form, but it set the focus on the text field AFTER the one I specified. I also specified with the GoToControl different controls on the main form and it did the same with those. It always sets focus to the control after the one I specify. Does anyone have any idea what is wrong with this?
David Torrey de Frescheville OP  @Reply  
     
16 months ago
Heres my code:

Private Sub GrowthFormCOMBO_KeyDown(KeyCode As Integer, Shift As Integer)

'The code below will set the focus from the GrowthFormCOMBO combobox on my subform to the HeightFromTEXTBOX field on
' the parent form (PlantsDatabaseF) when the TAB key is pressed

If KeyCode = 9 Then     '9 = TAB
        
        DoCmd.OpenForm "PlantsDatabaseF"
        DoCmd.GoToControl "HeightFromTEXTBOX"
        
    End If
End Sub
Richard Rost  @Reply  
          
15 months ago
You forgot to "swallow" the key press.

Private Sub GrowthFormCOMBO_KeyDown(KeyCode As Integer, Shift As Integer)
  
    If KeyCode = 9 Then    
        Parent!HeightFromTEXTBOX.SetFocus
        Keycode = 0 ' SWALLOW IT
    End If
    
End Sub
David Torrey de Frescheville OP  @Reply  
     
15 months ago
THANK YOU!!!! It worked!
Richard Rost  @Reply  
          
15 months ago
David Torrey de Frescheville OP  @Reply  
     
15 months ago
Thank you!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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: 6/16/2026 4:46:03 PM. PLT: 1s