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

Link text field to table from report

Status
Not open for further replies.

ceecld

Technical User
Jul 17, 2003
68
US
I have a query, (Current_Info), that gathers all the current data for parts of a generator. I want to print all the current info for each generator in a report. This isnt a problem.

I also have a table with a single entry that has the location of the site. In my report I want to header to show the name of the site, reading it from the table (site_name).

The problem is that i cannot include the name of the site in my current_info query. as it only has one record and one field. (Which doesnt link to the other tables) What i wanted to do was write a VB code to point a text field to tables!site_name!site_name. Not sure how to do this though.

Any ideas guys? or is there an easier way?



 
This may sound too simple, but I think this should solve your problem. I'm assuming you're using a command button on a form to view or print the report.

On that form, put an unbound text field (named SiteField, for example). Before you click the button that displays the report, enter the site location in that text field. I would probably use a combo box for that.

Next, put an unbound textfield on your form. Set it's value to [Forms]![MyForm]![SiteField]

When you view or print the report, the site will be right where you put your text field.
 
You can also use the DLookUp() function to get the value. In the Control Source for a text box on your Report put
=DLookUp("FieldNameInTable","TableName")

That should do it for you also. Just substitute the field name and table name in the function.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top