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

DLookup, 2001 error? tried to search 1

Status
Not open for further replies.

guysmiley01

Technical User
Mar 2, 2006
8
US
I've looked at a few FAQ's and the access help file and even some other posts but I can't seem to resolve my issue.
Maybe it would help if I really understood the error message. What does it really mean?

I have this in the click of a list control:

blabla = DLookup("[cust_name_first]", "qry_search", "[cust_id] = '" &
search_custid & "'")

Form!txt_namefirst.ControlSource = blabla

both "blabla" and "search_custid" are string.

Somehow I'm "canceling the previous operation.

Thank you in advance for any advice.
 
What about replacing this:
Form!txt_namefirst.ControlSource = blabla
with this ?
Form!txt_namefirst.Value = blabla

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for help PH however, the error is occuring prior to setting txt_namefirst

The error is in the DLookup so I'm not even getting to txt_namefirst

Does the syntax look correct?
 
No syntax appears incorrect.
I'm assuming cust_Id is numeric, ...remove quotes.

blabla = DLookup("[cust_name_first]", "qry_search", "[cust_id] = " &
search_custid )

but do pay heed to PHV's warning.
Once you get past the DLookUp error,
you're heading for another with,
Form!txt_namefirst.ControlSource = blabla



 
I have changed the controlsource to value.

both cust_id and search_custid are strings.
 
what data type, is blabla?
does search_custid, have a value?
Does DlookUp, have a value(is there such a record as such)?
 
all variables are strings.

search_custid is set just before the DLookup is supposed to take place and takes it value from the listbox

search_custid = List30.Value
I checked to see if it was passing the correct value by using a msgbox to display search_custid after setting it to list30.value and that works. it's just when I introduced the Dlookup that I started having issues.
 
Sorry gs01, I read your posts too fast.
You answered my questions already.
What value is your criteria?
Does it have intrusive punctuation, in it?
Is there such a record?
check your field & table name, in DLookUp,
are they spelled correctly?

 
The value ends up being a ssn.
Could it be that I'm referencing a query and not a table?
The query criteria is a function. The function get's it's value from "search_custid".
So could it be sort of like a circular reference? in that the query uses search_custid and then a dlookup is being performed on the query - also based on search_custid?

The query works, it's just the dlookup. I was trying to set an unbound textbox (txt_custname) based on the query without having to do a new recordset. I though dlookup is supposed to do that. But I'm stumped.
 
I'm sorry, you're saying your criterion search_custid ,
is a function? I thought it came from list30?

maybe assign a variable to search_custid

varID = search_custid

blabla = DLookup("[cust_name_first]", "qry_search", "[cust_id] = '" &
varID & "'")

Or it's a circular thing???
 
OH GOOD LORD!!!

Hello, my name is dipsh!t.

The field name in the query = "cust_custid" not "cust_id"
I am a big tard. I am sorry to have taken your time.

The listbox passes it's value to global sting which is used in a function and the function is used in the query.

amazingly enough, when you reference the correct field name - it works.

For you Zion7 - a star and a Golden Globe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top