Setting Focus on Navigation's Subform's and Its Control via Button Click VBA (1 Viewer)

accessonly11

Member
Local time
Today, 19:53
Joined
Aug 20, 2022
Messages
91
i am trying to get focus on subform control which have two parent forms

Main Form>Navigation Subform>OrderlineSubform.Control ProductID combo
how it is possible to get focus on this subform and then its control via add new button located on navigationSubform


i tried these two codes but failed and getting this error

[Forms]![Navigation Form]![NavigationSubform].[Form]![SaleDataSubform].SetFocus
[Forms]![Navigation Form]![NavigationSubform].[Form]![SaleDataSubform].[Form]![ProductID].SetFocus

Runtime error 2110
Microsoft Access can't move the focus to the control SaleDataSubform
 
Last edited:

Ranman256

Well-known member
Local time
Today, 10:53
Joined
Apr 9, 2015
Messages
4,337
you dont set focus on a form, you set it on a control in the form. (so the 1st line is useless)
Line 2 should work if you have the names correct. Did you use the BUILDER to get this path?
 

Minty

AWF VIP
Local time
Today, 15:53
Joined
Jul 26, 2013
Messages
10,371
You need to set focus to the Subform Control first not the form.
Once the Subform control has focus then set the focus to the control within the sub form.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:53
Joined
Feb 28, 2001
Messages
27,210
By way of clarification, the only time a form actually gets focus is when it has no enabled controls. Therefore, you cannot set focus on a form to which you expect to set focus on a control of that form. If the control.SetFocus would work, the form.SetFocus would not work.
 

Users who are viewing this thread

Top Bottom