Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple forms option in one subform

Status
Not open for further replies.

thefroggy

Technical User
Apr 20, 2004
31
GB
Hi,

I have a common form with only one subform box on it.

I have 3 possible forms for this subform space.
I would like to know if it is possible to open a given form in my subform depending on the information enter in my main form.

E.g: if I select "car" in a combo box from my main form, the subform should shows car's properties .

if I select "bike" in the same combo box than above, the same subform space should show up bike's properties.

Do you think that can be done?

Thanks

Steph
 
Im sure it can, but i am not sure my thoughts are the correct way.

I would do something like afterupdate of the combo

Put

If me!cmbname.value = "car" Then me.subform.form.controlsource = "Subformcarname"
elseif etc...

endif.

Let me know if that helps. You might want a refresh command in all of that too.



misscrf

It is never too late to become what you could have been ~ George Eliot
 
Thanks misscrf,

I've tried something based on the code you gave me which looked like that:

Private combo1_AfterUpdate
Me.MySubFormObject.Form.RecordSource = Me.Combo1
Me.MySubFormObject.Form.Requery
End Sub

but it is not working and the all link between Query/main Form and Subform must be wrong.
steph
 
This is in example of a main form with command buttons calling the same subform depending upon the button pressed. While not the same as your requirement, it might assist you.

Each subform opened has a query recordsource specifically set in these instances but recordsource manipulation is also possible.

Code:
    Select Case SubMenu
        Case 5
            DoCmd.OpenForm "frmSettingUp"
            [Forms]![frmSettingUp].Caption = "Employees"
            [Forms]![frmSettingUp]![frmSubForm].SourceObject = "frmEmployees"
            SubMenu = 0
        Case 6
            DoCmd.OpenForm "frmSettingUp"
            [Forms]![frmSettingUp].Caption = "Filleting and Defilleting Rates"
            [Forms]![frmSettingUp]![frmSubForm].SourceObject = "frmFilletingRates"
            SubMenu = 0
        Case 7
            DoCmd.OpenForm "frmSettingUp"
            [Forms]![frmSettingUp].Caption = "Contract Filleting Rates"
            [Forms]![frmSettingUp]![frmSubForm].SourceObject = "frmFilletingRatesContract"
            SubMenu = 0
    End Select
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top