Hide/Show Subform

G

Guest

I am using Access 2000 and I want to hide/show a subform [PropandContractsbf]
based on a yes/no box "ExhB?". "ExhB?" is located on the main form
[PropandContract].

I have an event "AfterUpdate" set on the "ExhB" control to refer to the
"Hide/Show" macro. This macro is as follows:
Condition: [Forms]![PropandContract]![ExhB?]=Yes; Action: SetValue; Item:
[Forms]![PropandContractsbf].[Visible]; Expression: Yes
Condition: [Forms]![PropandContract]![ExhB?]=Yes; Action: SetValue; Item:
[Forms]![PropandContractsbf].[Visible]; Expression: Yes

I have this main form located on another form where there are a total of 6
tabs including the one this form [PropandContract] is located.

When I check "ExhB?" I get a message "Microsoft Access cannot find the form
[PropandContract] referred to in a macro expression or Visual Basic code".

I have used something similar in another database and it worked fine but I
can't figure this one out.

Thanks for your help.
 
S

Steve Schapel

Don,

You can't refer to [Forms]![PropandContractsbf] in your macro argument.
The [PropandContractsbf] form is not open at the time (it is merely
displayed within the subform control on the main form). Just leave off
the Forms stuff. I would try it like this...

Condition: [ExhB?]=Yes
Action: SetValue
Item: [PropandContractsbf].[Visible]
Expression: Yes

Condition: [ExhB?]=No
Action: SetValue
Item: [PropandContractsbf].[Visible]
Expression: Yes

I am pretty sure this will do the trick. If not, you may need to use
the full reference to the sub-sub-form in the Item argument, something
like this...
[Forms]![MainForm]![PropandContract].[Form]![PropandContractsbf].[Visible]
 
G

Guest

Thanks. Your suggestion solved my problem.

Steve Schapel said:
Don,

You can't refer to [Forms]![PropandContractsbf] in your macro argument.
The [PropandContractsbf] form is not open at the time (it is merely
displayed within the subform control on the main form). Just leave off
the Forms stuff. I would try it like this...

Condition: [ExhB?]=Yes
Action: SetValue
Item: [PropandContractsbf].[Visible]
Expression: Yes

Condition: [ExhB?]=No
Action: SetValue
Item: [PropandContractsbf].[Visible]
Expression: Yes

I am pretty sure this will do the trick. If not, you may need to use
the full reference to the sub-sub-form in the Item argument, something
like this...
[Forms]![MainForm]![PropandContract].[Form]![PropandContractsbf].[Visible]

--
Steve Schapel, Microsoft Access MVP

I am using Access 2000 and I want to hide/show a subform [PropandContractsbf]
based on a yes/no box "ExhB?". "ExhB?" is located on the main form
[PropandContract].

I have an event "AfterUpdate" set on the "ExhB" control to refer to the
"Hide/Show" macro. This macro is as follows:
Condition: [Forms]![PropandContract]![ExhB?]=Yes; Action: SetValue; Item:
[Forms]![PropandContractsbf].[Visible]; Expression: Yes
Condition: [Forms]![PropandContract]![ExhB?]=Yes; Action: SetValue; Item:
[Forms]![PropandContractsbf].[Visible]; Expression: Yes

I have this main form located on another form where there are a total of 6
tabs including the one this form [PropandContract] is located.

When I check "ExhB?" I get a message "Microsoft Access cannot find the form
[PropandContract] referred to in a macro expression or Visual Basic code".

I have used something similar in another database and it worked fine but I
can't figure this one out.

Thanks for your help.
 
G

Guest

Steve, I thought I had this fixed but when I click the ExhB "yes/no" box it
will hide or show all of the subforms for all records rather than just the
one record I want it. Any suggestions? Thanks

Steve Schapel said:
Don,

You can't refer to [Forms]![PropandContractsbf] in your macro argument.
The [PropandContractsbf] form is not open at the time (it is merely
displayed within the subform control on the main form). Just leave off
the Forms stuff. I would try it like this...

Condition: [ExhB?]=Yes
Action: SetValue
Item: [PropandContractsbf].[Visible]
Expression: Yes

Condition: [ExhB?]=No
Action: SetValue
Item: [PropandContractsbf].[Visible]
Expression: Yes

I am pretty sure this will do the trick. If not, you may need to use
the full reference to the sub-sub-form in the Item argument, something
like this...
[Forms]![MainForm]![PropandContract].[Form]![PropandContractsbf].[Visible]

--
Steve Schapel, Microsoft Access MVP

I am using Access 2000 and I want to hide/show a subform [PropandContractsbf]
based on a yes/no box "ExhB?". "ExhB?" is located on the main form
[PropandContract].

I have an event "AfterUpdate" set on the "ExhB" control to refer to the
"Hide/Show" macro. This macro is as follows:
Condition: [Forms]![PropandContract]![ExhB?]=Yes; Action: SetValue; Item:
[Forms]![PropandContractsbf].[Visible]; Expression: Yes
Condition: [Forms]![PropandContract]![ExhB?]=Yes; Action: SetValue; Item:
[Forms]![PropandContractsbf].[Visible]; Expression: Yes

I have this main form located on another form where there are a total of 6
tabs including the one this form [PropandContract] is located.

When I check "ExhB?" I get a message "Microsoft Access cannot find the form
[PropandContract] referred to in a macro expression or Visual Basic code".

I have used something similar in another database and it worked fine but I
can't figure this one out.

Thanks for your help.
 
S

Steve Schapel

Don,

You will probably need to put the macro on the On Current event property
of the form, as well as the After Update event of the checkbox.
 

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