Dynamic subforms

  • Thread starter Thread starter ecapox
  • Start date Start date
E

ecapox

I have created a form, STATE INFORMATION, that automatically populates a
subform, STATE SUB, when a STATE is selected from a combo box and
repopulates the subform on every change of state....simple.

I am wanting to add another combo box called REGION on the same STATE
INFORMATION form and would like to have the choice of displaying the
information by state, when selecting a state or region, when selecting a
Region.

Is is possible to have either the REGION subform or STATE subform populate
the subform area on the STATE INFORMATION form? I do not want to recreate 2
forms with different subforms if i am able to pull either subform depending
on the selection chosen from the combo boxes.


emanuele
 
The subform control on the main form has a property related to its "source".
If you add code to the AfterUpdate event of the combo boxes (STATE, REGION),
you could modify "which" form serves as the source for the subform.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Upon searching and reading everyhting that had to do with Dynamic Forms, i
found this code that sets one subform visible and one inviosible depending on
certain criteria. Unfortunately i do not understand how to write it in VBA.

if certainparameters Then
ME.subformcontrol1.visible = false
Me.subformcontrol2.visible = true
Else
ME.subformcontrol1.visible = true
Me.subformcontrol2.visible = false
End If

Could i get examples of the ME, subformcontrol1, and subformcontrol2? I do
not know what to put in those fields.

if forms.state information.state = "" Then

subform.state.visible = false
subform.Region.visible = true
Else
subform.state.visible = True
subform.Region.visible = False
End If

This seem correct? I tried it but it did not work. And i am aware that this
even procedure goes into the properties of the combo box under "After Change"

Jeff said:
The subform control on the main form has a property related to its "source".
If you add code to the AfterUpdate event of the combo boxes (STATE, REGION),
you could modify "which" form serves as the source for the subform.

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have created a form, STATE INFORMATION, that automatically populates a
subform, STATE SUB, when a STATE is selected from a combo box and
[quoted text clipped - 13 lines]
 
Sorry for the absence...

You'll need to understand a bit about Events (e.g., AfterUpdate) to handle
what you're describing. You might not need to use VBA if you can get Macros
to do what you want.

The simple logic, if I understand what you're trying to do, is something
like:

If YourComboBox = xxxxx Then
Me.subfrmYourSubformControl.RecordSource = "TheNameOfTheForm"
ElseIf YourComboBox = yyyy Then
Me.subfrmYourSubformControl.RecordSource = "TheNameOfTheOtherForm"
EndIf

Check Access HELP for examples of the exact syntax that goes with the
RecordSource.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top