Error while executing following code relating DLookup

dhyadav

New member
Local time
Today, 14:21
Joined
Sep 9, 2018
Messages
2
Hi everyone.

Error while executing following code relating DLookup

RightUser = DLookup("[UserRights]", "tblRights", "[FormName]=" & Me.name & " " & "And [EmplUserName]='" & TempVars(EmplUserName) & "'")


this gives the error "Data type mismatch in criteria or expression".

Any ideas? I'm sure it's a minor error but I'm really stumped!!

Thanks in advance,

Dharmesh
 
I moved your post to the general section
 
I believe you will need single quotes surrounding Me.name as you have done for Tempvars?
Get rid of the " " string and just prefix And with a space

HTH
Hi everyone.

Error while executing following code relating DLookup

RightUser = DLookup("[UserRights]", "tblRights", "[FormName]=" & Me.name & " " & "And [EmplUserName]='" & TempVars(EmplUserName) & "'")


this gives the error "Data type mismatch in criteria or expression".

Any ideas? I'm sure it's a minor error but I'm really stumped!!

Thanks in advance,

Dharmesh
 
Hi HTH

After modifying as mentioned below, my code is as follows :-

RightUser = DLookup("[UserRights]", "tblRights", "[FormName]='" & Me.name & " And [EmplUserName]='" & TempVars("EmplUserName") & "'")

(Want to retrieve UerRights (numeric value) based on two criteria One is Form Name (String) and Second is User Name (String)

However following Error occurs

syntax error (missing operator) in query expression '[FormName] = 'frmlogin and [EmplUserName]='ADMIN''.

Kindly guide me for above code

Dharmesh
 
You forgot a single quotes after the "Me.name":
Code:
 "... [FormName]='" & Me.name & "[B][COLOR=Red]'[/COLOR][/B] And [EmplUse ...
 

Users who are viewing this thread

Back
Top Bottom