Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding a control on a report in response to a field

Status
Not open for further replies.

RobSimpson

IS-IT--Management
Sep 17, 2002
35
GB
Sorry if this has already been posted but I can't find the answer I need on the forum.

I have written a report that produces 25 pages, one for each person in the database. The report contains a couple of fields from the underlying query and a subreport pulling in information about the person from another table.

I would like to hide or show some 'non-content' items on each page of the report, boxes, labels etc depending on one of the fields in the query (hap - which is a true/false) but I can't work out which event on the property page of the report to use.

I was thinking of using the VBA line

me.box.visible = me!hap

but just can't get it to work. Probably something obvious but I just can't get it.

Any help gratefully received.

Robert
 
Robert
Assuming that the field might be in the Detail section, can you put your code on the Format event for the Detail section?

Tom
 
Thanks for that Tom. I've got the code in the right place and I can force it to work but it won't work automatically.

My problem seems to be the reference to the field from the underlying query.

The field is 'hap'. I'm referring to it as above:

Me.box.properties("Visible") = Me!hap

However, VBA stops at this line saying that

"Microsoft Office cannot find the field 'hap' referred to in your expression."

Am I getting the referencing wrong? I've had no problems in controls using the field names but it seems not to work in the VBA.

In the end, my solution was to put a checkbox control on the report (hidden) and then the code works fine, just as I wanted it to. It doesn't seem very 'elegant' though.

Thanks

Robert
 
Robert,
You seem to have found the solution by placing a control on the report that is bound to your field. I am not aware of another work-around.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks a lot to both of you for your suggestions.

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top