Then, my guess is Access cannot resolve Me.Name_Choose. Either that or there's some incorrect spelling in there somewhere. Double-check the spelling for [Category_Name] and [Company Name]. Otherwise, consider posting a small copy of your db, so we can take a look.No, [Sales Tax Table] is a table.
Run=time error '3061'
Too few parameters, Expected 1.
I'm trying to retrieve the value in the 'Category' field of the 'Sales Tax Table' table with a VBA SQL statement.
Dlookup("Category","Sales Tax Table","Company Name= '" & Me.Name_Choose & "'")
Dlookup("Category","[Sales Tax Table]","[Company Name]= '" & Me.Name_Choose & "'")
Dlookup("Category","Sales Tax Table","Company Name= '" & Me.Name_Choose & "'")
I never use space in my fields naming and didn’t know we have to use breakets in Dlookup in this case. I thought its just for sql statements.Actually, Tera and lhooker, you would use:
Code:Dlookup("Category","[Sales Tax Table]","[Company Name]= '" & Me.Name_Choose & "'")
That is, presuming that [Company Name] is a field of [Sales Tax Table] and so is [Category]. You need the brackets for the domain and for the criterion because the field names have spaces in them. So the brackets are mandatory. Might get away with leaving off the brackets for [Category] since it shows no spaces in the name. Tera is right that you don't need SQL because a DLookup will do what you want from VBA.
Whoops! I meant to say .Openrecordset might behave similar to what I've read about .Execute.- as a test, you could try Openquery method since it's a select query. If it runs, that indicates to me that the .Execute method doesn't pre-process the sql ( as I've read), thus the references aren't evaluated first.