caryisms,
You just put, in double quotes the 3 arguments:
x = Dlookup("fieldname","table_or_Query_name","Criteria without WHERE"
ie:
x = Dlookup("CustName","tblCustomers","CustID = 100"
If you're using this in code, and have a variable for the criteria (or field and tablename, for that matter), do this:
x = Dlookup("CustName","tblCustomers","CustID = " & variable)
If custID is a string:
x = Dlookup("CustName","tblCustomers","CustID = '" & variable & "'"
You can put multiple criteria, ie
x = Dlookup("CustName","tblCustomers","CustCity = '" & variable & "' AND Gender = 'M'"
Remember, that 'x', or the return value, must be able to accept a NULL. So either make x a variable, or wrap dlookup in NZ(), ie:
dim x as string
x = nz(Dlookup("CustName","tblCustomers","CustCity = '" & variable & "' AND Gender = 'M'","<Not Found>"
Jim, Thanks for your response to the question about using DLookup. I tried to find official documentation about this and other domain aggregate functions without success. Isn't there official Microsoft documentations somewhere for describing these functions? Alternatively, is there an unofficial location for all Access documentation? I can't believe there isn't a reference to these functions in the online help that comes with Access.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.