Hide/Show Subform

G

Guest

I want to hide or show a subform based on the value of [Account#] but I can’t
seem to get it to work. If [Account#]=â€392†or “396†I want to show the
subform otherwise hide it. I have created the following macro and have
included it in the “After Update†Event on the [Account#] control. I also
have included this in the “On Current†Event of the form to hide/show when
moving from form to form.

Hide/ShowVehicleForm
[Forms]![CapitalItems]![Account#]="392";
Item: CapitalItems]![Vehiclessbf].[Visible]
Expression: Yes
[Forms]![CapitalItems]![Account#]="396"
Item: CapitalItems]![Vehiclessbf].[Visible]
Expression: Yes
[Forms]![CapitalItems]![Account#]<>"392"
Item: CapitalItems]![Vehiclessbf].[Visible]
Expression: No
[Forms]![CapitalItems]![Account#]<>"396"
Item: CapitalItems]![Vehiclessbf].[Visible]
Expression: No

Thanks for your help.
 
S

Steve Schapel

Don,

First of all, there appears to be a missing [ in the 'Item' argument. I
am not sure whether this is a typo in your post here, or whether this is
really in your macro.

In any case, [CapitalItems]![Vehiclessbf].[Visible] doesn't really make
sense.

In addition, since the thing is all happening on the CapitalItems form
anyway, you don't need to qualify this in your macro.

I also see you have a rogue ; at the end of the first Condition statement.

Are the values in the AccountNumber field numbers or text data type. If
they are numbers, it is not correct to enclose them in ""s.

You will note that I have changed from Account# to AccountNumber. It is
not a good idea to use a # as part of the name of a field or control.

So, try like this:

Condition: [AccountNumber]=392 Or [AccountNumber]=396
Action: SetValue
Item: [Vehiclessbf].[Visible]
Expression: Yes

Condition: ...
Action: StopMacro

Condition: <blank>
Action: SetValue
Item: [Vehiclessbf].[Visible]
Expression: No

First condition could also be written like this:
Condition: [AccountNumber] In(392,396)
 

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