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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why do I need to have the field in the report if it is in the query?

Status
Not open for further replies.

Cosette

Technical User
Nov 30, 2004
98
US
Hi all,

This is rather theoretical, but I don't understand it. If I have all my field names in my query as 'show', and they show in the field list of the report, I shouldn't have to put them in the report grid for a report with code to run - is that correct?

For example, I have the field married, and code that starts if [married] = 0....

In my report, if married is not in the grid, the code won't run.

Thank you for your replies
 
In all version of Access that I have tried, you MUST bind the field to a control in order to reference its value in code. The control can be invisible.

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]
 
The reason has to do with default properties and methods. I believe when you type [married] = 0, and married is a control what is really happening is Me.Controls("Married").value = O. The Controls collection is the default collection so you are working with a value in a control on a report not with a value in a recordset. That is why if your control has a name like txtBxMarried, txtBxMarried = 0 will work but married = 0 will not.
 
Thank you both for clarifying a puzzling problem. Now I understand better.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top