G
Guest
I can hide or show a field in a form in the properties using visible Yes or
No.
Is it also possible to hide or show fields using a macro ?
No.
Is it also possible to hide or show fields using a macro ?
Steve Schapel said:Louis,
Just to add to Ken's comments, you can use a SetValue action in a macro
to do this.
For example, suppose you have a textbox named MyTextbox on a form which
you want to hide, the macro would be like this...
Action: SetValue
Item: [MyTextbox].[Visible]
Expression: No
The next thing to decide is what is the appropriate Event you will use
to trigger this action.
--
Steve Schapel, Microsoft Access MVP
There are no fields on a form; just controls. The Visible property is used
to hide/show controls on a form (or a report).
On which object are you wanting to hide "fields"?
Steve Schapel said:Ben,
VBA would provide no advantage compared with macro, you would still need
to take care of the same thing.
Your macro that runs on the Current event needs to take care of both
possibilities, and set the visibility of the 2ndReentryDate control
based on whether there is data in the ExitDate2. That means this macro
will need two SetValue actions, one to make 2ndReentryDate visible, and
one to hide it. You would put a Condition for these two actions, i.e.
[ExitDate2] Is Not Null
[ExitDate2] Is Null
--
Steve Schapel, Microsoft Access MVP
Ben said:Thanks Steve. That get's me a bit closer. One more step.
Now, due to the SetValue, Visible = Yes in the AfterUpdate event of
ExitDate2, 2ndReentryDate appears on the form as needed.
Due to the re-set of 2ndReentryDate to Visible = No in the form's On Current
event, when the form focuses on a different record (I think that is the right
terminology), the 'appeared' control goes away (as it should).
However, when I go back to the record that I entered ExitDate2 for,
2ndReentryDate is still not visible (i.e. the visible doesn't persist). I
get why, because the On Current says "hide it" and its only AfterUpdate that
it says "appear it" (as non-db language as that description is) and I'm not
updating the control (because I already did). What I need now is some way to
say "If ExitDate2 is not Null, then 2ndReentryDate should stay visible."
At this point, I've been doing all of this using the Macro function and
expression builder. I have the sense I'm sliding towards the need or VBA, at
this point.
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.