I WANT TO USE DLOOKUP TO SHOW SOME DATA BUT WITH SOME CONDITIONS

J

jehad hindi

I USED TO WORK WITH DLOOKUP WITH ONE CONDITION TO SHOW SOME DATA BUT I DO NOT
HAVE PROBLEM FOR THIS BUT I WANT TO SHOW SOME DATA WITH USING DLOOKUP WITH
THRE CONDITIONS FOR EXAMPLE:

Dim Show As Boolean
Show = DLookup("SSHOW", "UsersPermission", "[UserName] =
Forms![Main]![SUserName]" And [formName] = Me.formName)
If Show = False Then
MsgBox " You dot not have permission to run this form "
DoCmd.Close
SO WHEN I DO THIS FUNCTION I GOT ERROR BUT I DO NOT KNOW THE REASON SO I
NEED HELP
 
T

Tom Lake

jehad hindi said:
I USED TO WORK WITH DLOOKUP WITH ONE CONDITION TO SHOW SOME DATA BUT I DO
NOT
HAVE PROBLEM FOR THIS BUT I WANT TO SHOW SOME DATA WITH USING DLOOKUP WITH
THRE CONDITIONS FOR EXAMPLE:

Dim Show As Boolean
Show = DLookup("SSHOW", "UsersPermission", "[UserName] =
Forms![Main]![SUserName]" And [formName] = Me.formName)
If Show = False Then
MsgBox " You dot not have permission to run this form "
DoCmd.Close
SO WHEN I DO THIS FUNCTION I GOT ERROR BUT I DO NOT KNOW THE REASON SO I
NEED HELP

Is UsersPermission the name of the table you're searching? According to
your DLookup, it should be. SSHOW, UserName and formName must be field
names in the UsersPermission table.

Try this:

Show = DLookup("SSHOW", "UsersPermission", "[UserName] = '" &
Forms![Main]![SUserName] & "' And [formName] = '" & Me.formName & "'")

Tom Lake
 
Top