Conditional Field Display

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have a report that is opened from a form.

The form passes a value to the report that specifies whether a certain field
should or should not be displayed in the reoprt. If the user selects "full"
on the form, the value 1 (true) is passed and the field should be
displayed.

However, I cannot get the syntax for this to work. Currently the optional
field control source is:

=IIf(me!txtFull=1,"",[opt_field_name])

This gives me an #error message.

Should this work? Is there a better way? If so, how should I code this?

Thanks
Dave
 
I have a report that is opened from a form.

The form passes a value to the report that specifies whether a certain field
should or should not be displayed in the reoprt. If the user selects "full"
on the form, the value 1 (true) is passed and the field should be
displayed.

However, I cannot get the syntax for this to work. Currently the optional
field control source is:

=IIf(me!txtFull=1,"",[opt_field_name])

This gives me an #error message.

Should this work? Is there a better way? If so, how should I code this?

Thanks
Dave
1) Me is a VBA keyword, not an Access keyword.
You cannot use the Me! keyword in an Access control source expression.

2) Regarding: > the value 1 (true) is passed <
How is it 'passed'? To where in the report? When?

3) What value is being passed? 1 or True.
The value of True is -1, not 1.

4) if you mean to show the field [opt_field_name], if the value is 1
(or -1) you have reversed the logic.

5) If the form remains open (Not Visible is OK), then you don't need
to 'pass' anything.

If the value in the form control is 1:
=IIf(forms!FormName!ControlName = 1,[opt_field_name],"")

If the value in the form control is True (-1):
=IIf(forms!FormName!ControlName = -1,[opt_field_name],"")

If the value is 1 (or -1) the [opt_field_name] will show, otherwise it
will not.

Make sure the name of this control is not the same as any field used
in it's control source expression.

Close the form in the Report's Close event.
 
That works

Thanks


fredg said:
I have a report that is opened from a form.

The form passes a value to the report that specifies whether a certain
field
should or should not be displayed in the reoprt. If the user selects
"full"
on the form, the value 1 (true) is passed and the field should be
displayed.

However, I cannot get the syntax for this to work. Currently the
optional
field control source is:

=IIf(me!txtFull=1,"",[opt_field_name])

This gives me an #error message.

Should this work? Is there a better way? If so, how should I code this?

Thanks
Dave
1) Me is a VBA keyword, not an Access keyword.
You cannot use the Me! keyword in an Access control source expression.

2) Regarding: > the value 1 (true) is passed <
How is it 'passed'? To where in the report? When?

3) What value is being passed? 1 or True.
The value of True is -1, not 1.

4) if you mean to show the field [opt_field_name], if the value is 1
(or -1) you have reversed the logic.

5) If the form remains open (Not Visible is OK), then you don't need
to 'pass' anything.

If the value in the form control is 1:
=IIf(forms!FormName!ControlName = 1,[opt_field_name],"")

If the value in the form control is True (-1):
=IIf(forms!FormName!ControlName = -1,[opt_field_name],"")

If the value is 1 (or -1) the [opt_field_name] will show, otherwise it
will not.

Make sure the name of this control is not the same as any field used
in it's control source expression.

Close the form in the Report's Close event.
 
Back
Top