I've read quite a lot of dlookup examples trying to get the correct syntax, and I keep getting errors. This is what I'm doing...
On a form, user chooses their name from a combobox cboUserName.
Combobox is populated with chrUserName from tblUsers.
I make a public variable strUserName equal that because I'm going to use it for lots of things.strUserName = Me.cboUserName
I know that's working because I then...MsgBox strUserName
and it always returns the correct name.
So I also want to find that strUserName in the field chrUserName on tblUsers to find the corresponding chrAccessLevel in that record.
I want it stored in public variable strAccessLevel for use throughout the database.
I feel this should work:
strAccessLevel = DLookup("chrAccessLevel", "tblUsers", "chrUserName=strUserName")
Run-time error '2471':
The expression you entered as a query parameter produced this error: 'strUserName'
What am I missing?