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

using Dlookup in a report

Status
Not open for further replies.

ruthcali

Programmer
Apr 27, 2000
470
US
i am using Access97.

On my form, i have a text box with the following control source:

=DLookUp("[rackloc]","tblOPCInfo","[BuildingSite]=Form.[BuildingSite] and [SystemID]=Form.[SystemID] and [OPCNumber]=Form.[OPCNumber]")

that works fine on my form. but, i tried the same thing on my report and had no luck.
on my report, my text boxes's control source is:

=DLookUp("[rackloc]","tblOPCInfo","[BuildingSite]=Forms![frmOPCCNET]![BuildingSite] and [SystemID]=Forms![frmOPCCNET]![SystemID] and [OPCNumber]=Forms![frmOPCCnet]![OPCNumber]")

That only works for the first value in my report. Then, that value is repeated for every line in the report! So every line in the report has the same data.

Does anyone know to get fix this?

thanks,
ruth

 
Silly me. i figured it out.

On my report, i shouldn't refer to my form, i should refer to my report!!

i changed the control source of my report's text box to:

=DLookUp("[rackloc]","tblOPCInfo","[BuildingSite]=[Reports]![rptCnet]![BuildingSite] and [systemid]=[Reports]![rptCNET]![systemid] and [OPCNumber]=[Reports]![rptCNET]![OPCNumber]")

and it works!

But, it's strange that i didn't need to add any formatting:(ex: & and "'")

so, i didn't need to type:
"[BuildingSite]='"&[Reports![rptCnet]![BuildingSite] & "'"

it works with just:
"[BuildingSite]=[Reports]![rptCnet]![BuildingSite]

does anyone know why?
 
I still can't get my report to lookup a description from a table. =DLookUp("[res description]","[res codes]","[res code]=[Reports]![RES]![res code]")
 
Strange, your code looks right.

so res codes is the name of your table?

and in your table, you have a field called res code.

and res code is the text box in your report?

double check your field names. if you would like, you can email me your database and i'll try to help.
ruth.jonkman@wcom.com
 
I forget the specifics, but somewhere I recall that spaces in table and field names is a no-no.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top