Opening one of multiple subforms based on critera of the main form

Joined
Jul 12, 2011
Messages
7
Reaction score
0
Basics: I'm running windows 7 (32-bit) with Access 2007

I currently have a Form that will open based on a user entering in a TS # (ID#) and shows various record information…your basic form.
My problem is that I need to open one of several sub forms within this form based on the state of the ID #. I already have code for opening the form based on state…

If [Forms]![Call_Form_1]![State] = "AZ" Then
DoCmd.OpenForm ("Accouting_Form")
DoCmd.GoToControl "TS #"
DoCmd.FindRecord Forms![Call_Form_1]!TS, acEntire, False, , False, acCurrent, True
On Error GoTo 0

‘Call_Form_1 is a quick form I use that shows only the TS# (ID#) and the state, so I do not have to open a larger form, and is programmed to close itself after use.
‘If you can think of a better way of writing this, I’m all for it

My actual problem comes in as I have looked online and tried:
Forms![MainFormName].[SubformName].Value

Or in my case:
Forms![Accounting_Form_AZ]![Acc_Subform]![Accounting_AZ_FC]

But have had no luck.


Any help on this matter would be greatly appreciated
Thank you,

David92595
 
Joined
Dec 12, 2011
Messages
6
Reaction score
0
Basics: I'm running windows 7 (32-bit) with Access 2007

I currently have a Form that will open based on a user entering in a TS # (ID#) and shows various record information…your basic form.
My problem is that I need to open one of several sub forms within this form based on the state of the ID #. I already have code for opening the form based on state…

If [Forms]![Call_Form_1]![State] = "AZ" Then
DoCmd.OpenForm ("Accouting_Form")
DoCmd.GoToControl "TS #"
DoCmd.FindRecord Forms![Call_Form_1]!TS, acEntire, False, , False, acCurrent, True
On Error GoTo 0

‘Call_Form_1 is a quick form I use that shows only the TS# (ID#) and the state, so I do not have to open a larger form, and is programmed to close itself after use.
‘If you can think of a better way of writing this, I’m all for it

My actual problem comes in as I have looked online and tried:
Forms![MainFormName].[SubformName].Value

Or in my case:
Forms![Accounting_Form_AZ]![Acc_Subform]![Accounting_AZ_FC]

But have had no luck.


Any help on this matter would be greatly appreciated
Thank you,

David92595

I believe (though not sure) that you only need the name of the subform, (Not the main form aswell) as this is technicaly a form in it's self

So try:

Code:
[Forms]![Acc_Subform]![Accounting_AZ_FC]

Hope this works,
Tommy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top