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

DLookup causing error 2450 2

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I have created a Dlookup that is giving me a error 2450. The form name is frmReports1, textbox to enter info in is txtUCI, the txtbox I want the info to go in is txtRpt. the queryname is qry_sel_dbo_rptq_rpts_frm and the name of the first field from the table is qrptid, the name of the lookup field from the query is uci. Any help is appreciated.
Tom

Code:
Me!txtRpt = DLookup("qrptid", "qry_sel_dbo_rptq_rpts_frm", "[UCI] =""" & Forms!Me![txtUCI] & """")
 
At least, replace this:
Forms!Me![txtUCI]
with this:
Me![txtUCI]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I did that change and I get the same error.

Code:
Me!txtRpt = DLookup("qrptid", "qry_sel_dbo_rptq_rpts_frm", "[UCI] =""" & Me![txtUCI] & """")
 
You may need a single quote instead of double, just a guess here...
[tt]
, "[UCI] = '" & Me![txtUCI] & "'")
[/tt]

or - if UCI is a number:
[tt]
, "[UCI] = " & Me![txtUCI])
[/tt]


Have fun.

---- Andy
 
txtUCI is a text field. I tried Andy's code and now I get an
Error 2001 You cancelled the previous operation.

Tom
 
I the query that this Dlookup is based on has a criteria [Enter UCI] in it will this cause Error 2001?
 
Have a look here:
faq701-6763

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks Andy and PHV it works! I removed the criteria in the query and it works.
The table has multiple fields in it that I need to know the information in. Do I add the fields in this DLookup statement Or do I have multiple Dlookup statements with the different fields? I would like the information to go across the text box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top