Help: hide/show fields depending on other field

F

Fjordur

Hi,
I have a report based on a query. The query returns,say, 3 fields: A
(True/false), ATrue (text), AFalse (text). Whenever A is true I want to
display field ATrue (and not display AFalse), and vice-versa. I don't want
an empty field on the report.

What I did is this:
1. put a text field called AText in the report
2. together with a label called LabelAText
3. write a macro with conditional:
[A] setValue [AText].[ControlSource] "ATrue"
... setValue [LabelAText].[Caption] "blah blah"
not [A] setValue [AText].[ControlSource] "AFalse"
... setValue [LabelAText].[Caption] "another blah blah"
4. attach the macro to various events of the report

Depending on the event I attach the macro to, either I get a macro failure
or the fields do NOT change on the report.

What's the mistake? Am I entirely on the wrong track? I'd rather not use VB
it this can be done with macros...

Thanks for the time
 
M

Marshall Barton

Fjordur said:
I have a report based on a query. The query returns,say, 3 fields: A
(True/false), ATrue (text), AFalse (text). Whenever A is true I want to
display field ATrue (and not display AFalse), and vice-versa. I don't want
an empty field on the report.

What I did is this:
1. put a text field called AText in the report
2. together with a label called LabelAText
3. write a macro with conditional:
[A] setValue [AText].[ControlSource] "ATrue"
... setValue [LabelAText].[Caption] "blah blah"
not [A] setValue [AText].[ControlSource] "AFalse"
... setValue [LabelAText].[Caption] "another blah blah"
4. attach the macro to various events of the report

Depending on the event I attach the macro to, either I get a macro failure
or the fields do NOT change on the report.

What's the mistake? Am I entirely on the wrong track? I'd rather not use VB
it this can be done with macros...


You might be on the wrong, or at least a complicated, track.

I think you only need one text box with an expression:

=IIf(A, Atext, AFalse)
 
F

Fjordur

Marshall Barton said:
Fjordur said:
I have a report based on a query. The query returns,say, 3 fields: A
(True/false), ATrue (text), AFalse (text). Whenever A is true I want to
display field ATrue (and not display AFalse), and vice-versa. I don't want
an empty field on the report.

What I did is this:
1. put a text field called AText in the report
2. together with a label called LabelAText
3. write a macro with conditional:
[A] setValue [AText].[ControlSource] "ATrue"
... setValue [LabelAText].[Caption] "blah blah"
not [A] setValue [AText].[ControlSource] "AFalse"
... setValue [LabelAText].[Caption] "another blah blah"
4. attach the macro to various events of the report

Depending on the event I attach the macro to, either I get a macro failure
or the fields do NOT change on the report.

What's the mistake? Am I entirely on the wrong track? I'd rather not use VB
it this can be done with macros...


You might be on the wrong, or at least a complicated, track.

I think you only need one text box with an expression:

=IIf(A, Atext, AFalse)

Marshall ,
When I woke up this morning I thought of trying this, and of course you're
right, this is much simpler. Thanks for the help.
 

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