VBA in Access Problem with fields being recognized

Viewed 83

I have a report form for labels. It worked just fine until I tried to add a test for the presence of a "Special_Label" flag in the table.

I coded If Me.Special_Label <> Null then (and after typing the Sp I got the full name of the field in the dropdown and selected it). But when I run the report I get a message #2465 "Can't find the field 'Special_Label' referred to in your expression".

I have other "Me."fields in the code and they are printed in the label just fine.

I added a Me.RecordSource = "tblHomeOwner" in the report open but that made no difference. It was actually already in the definition of the report.

Trying to learn more about the error, I put in another field instead of Special_Label and it was not found either. So I am really curious why the processing of the code entry can list the fields of the table for use, but they cannot be found at run time.

As near as I can tell there are no queries involved in this report. I can see nothing that would restrict the fields available at run time.

1 Answers

Unlike forms, depending on event code is in and whether you use dot (Me.) or bang (Me!), report could require field referenced in code to also be placed in a textbox. Without bound textbox, using bang in Load event does not error, dot will; both error in Open event.

Bind a textbox to the field. If you don't want value to show, set textbox Visible property to No.

Related