Help With Nested Subforms (Access 2016) (1 Viewer)

VBA-ish

Registered User.
Local time
Today, 13:29
Joined
Aug 8, 2016
Messages
16
I've searched for a few hours and have not been able to find a solution. I am using the NavigationForm with a subform (frmSetup) as one of the tabs. Within frmSetup, I have a combobox that loads another form within frmSetup's subform (fsubSetup). Within one of the possible forms that can be loaded into fsubSetup there is a combobox that selects an employee (cboEmployee), then uses the selection to be used in a listbox's (lstEntities) query during cboEmployee's AfterUpdate event.
So basically, the hierarchy is something like this: NavigationForm>frmSetup>fsubSetup>cboEmployee

I can get everything to work as intended when it's not being placed into the NavigationForm. However, when trying to use it within the NavigationForm, if I set fsubSetup's Source Object manually in its properties to the form that contains cboEmployee and lstEntities (frmIndividualTracking_Entities) and then go into the listbox's build event, frmIndividualTracking_Entites is shown as a report and it won't let me go any further to reach cboEmployee. (image attached)
Also, I should mention that everything works as it should if frmIndividualTracking_Entities is placed directly within the NavigationForm (no frmSetup).


Is this possible to do? Can it be done with VBA? Any help would be appreciated.
 

Attachments

  • 1.PNG
    1.PNG
    6.5 KB · Views: 99
  • 3.PNG
    3.PNG
    21.1 KB · Views: 90

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:29
Joined
Feb 19, 2002
Messages
43,424
Navigation forms only allow a single subform to be loaded at one time. You can probably do what you want if you ditch the navigation form and build your own using a tab control.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:29
Joined
May 7, 2009
Messages
19,246
you don't need to reference the listbox on the sub, subform using NavigationForm>frmSetup>fsubSetup>cboEmployee.

just add code to the listbox or combobox as usual (using Code Builder) using Me.comboname or Me.listName.
 

VBA-ish

Registered User.
Local time
Today, 13:29
Joined
Aug 8, 2016
Messages
16
Navigation forms only allow a single subform to be loaded at one time. You can probably do what you want if you ditch the navigation form and build your own using a tab control.

Are you sure? I can get three (counting the NavigationForm's sub). See attachment.


you don't need to reference the listbox on the sub, subform using NavigationForm>frmSetup>fsubSetup>cboEmployee.

just add code to the listbox or combobox as usual (using Code Builder) using Me.comboname or Me.listName.

Maybe I'm not following you, but that doesn't work when calling the sub from the Navigation form. It only works when the form containing the sub is loaded on its own.

*Edit:
For simplicity's sake, I recreated this scenario in a separate DB and named things so they're easy to follow. See attachment for reference.
The NavigationForm's subform (Sub 1) contains a form with a combobox and subform (Sub 2) that then loads other forms based on the selection, but for this example in particular it's a form containing a combobox and listbox (Sub 3). The combobox in Sub 3 populates the listbox (this is what I'm trying to accomplish).
 

Attachments

  • ThreeSubs.PNG
    ThreeSubs.PNG
    11.8 KB · Views: 82
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:29
Joined
May 7, 2009
Messages
19,246
so the most inner combo you need to retrieve:

MsgBox Forms![NavigationFormName]![NavigationSubform]![fSubSetUp].Form![comboName] & ""

change the purpled letter to correct form/control name.
 

VBA-ish

Registered User.
Local time
Today, 13:29
Joined
Aug 8, 2016
Messages
16
so the most inner combo you need to retrieve:

MsgBox Forms![NavigationFormName]![NavigationSubform]![fSubSetUp].Form![comboName] & ""

change the purpled letter to correct form/control name.

Using the Expression Builder, correct? When I try the above I am still prompted to enter parameters, and when using [MsgBox Forms] I also get a syntax error. Speaking of which, I'm not familiar with that particular tag; what's the significance of adding MsgBox?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:29
Joined
May 7, 2009
Messages
19,246
Im no using exor builder.
For a test add a button to the main navigation form, just beside the title.
Add code to the click event.
Use the msgbox i gave you.
Make sure that you put the correct navigation form name and combo name.
Bring the nav firm to normal view.
Select something on the combo.
Press the bew button.
 

Minty

AWF VIP
Local time
Today, 18:29
Joined
Jul 26, 2013
Messages
10,371
If you put the nested forms into a normal form then the normal subform syntax will apply.

The inbuilt Navigation form does exactly what Pat said. It uses a sub form loading routine to load the tabs on demand, but hides that from you, and makes life difficult.
 

VBA-ish

Registered User.
Local time
Today, 13:29
Joined
Aug 8, 2016
Messages
16
Im no using exor builder.
For a test add a button to the main navigation form, just beside the title.
Add code to the click event.
Use the msgbox i gave you.
Make sure that you put the correct navigation form name and combo name.
Bring the nav firm to normal view.
Select something on the combo.
Press the bew button.

Okay, that makes more sense - I misread the prior reference to the code builder as Expression Builder.

When I click the button it returns the value in the combobox.
 

VBA-ish

Registered User.
Local time
Today, 13:29
Joined
Aug 8, 2016
Messages
16
Okay, that was enough to get me pointed in the right direction and now it's working. Thanks!
 

Users who are viewing this thread

Top Bottom