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

DLookUp headache 1

Status
Not open for further replies.

abradford

MIS
Oct 12, 2006
31
US
I have this DLookUp in the control source of an unbound text box on a report.

=DLookUp("AgentNum","AgentLookup","BSONum = " & [BSO])

lookup table:

name: AgentLookup
1st column - BSONum
2nd column - AgentNum

my report is opened by a parameter asking what BSO, which is a number (could be number and text, 1111b) simply, I need the text box to look up the number of people in a certain BSO. I get an #error on the report. this code was copied exactly from my sample DB, where there it worked fine...any ideas on why it’s not working?
 
Assuming BSO is a text field in the report's record source then try:
=DLookUp("AgentNum","AgentLookup","BSONum = """ & [BSO] & """")

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]
 
Spot on Duane, thanks again for the help. So it was just missing the extra parens and a &...was this strictly because it was a text field, not number?
 
Your expression would have worked if the value was numeric. Since it is text/string, you must use quotes.

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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top