Results 1 to 6 of 6
  1. #1
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58

    Dlookup function using OR criteria for one field

    Having some difficulty with this syntax. Could someone help me clean this up.
    I need to allow users to open a form if there user role is one of two roles.
    My code runs but it doesn't recognize the criteria correctly .
    Here is what I have written as of now...

    If (DLookup("strUserRole", "tblUserLogin", "[strUserID]='" & Forms![_frmLoginVerify]!txtLoginName.Value & "'")) = " 'Consultant' & Or & 'PSR_A' " Then

    Thanks in advance for your help.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    You don't need the .value

    you can't use 1 statement = a or b, it must be...
    staetement=a or statement=b

  3. #3
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58
    Thanks... I took you wrote and tried as two IF functions and seems to work. Thanks again for quick reply

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You can try
    Code:
    Dim  txtUserID as String
    
    'look up a value
    txtUserID = DLookup("strUserRole", "tblUserLogin", "[strUserID]='" & Forms![_frmLoginVerify]!txtLoginName & "'")
    
    
    If txtUserID  = "Consultant" Or txtUserID  = "PSR_A" Then
    
         ' other statements
    
    End If
    You really have a form named "_frmLoginVerify" (underscore as the first character) ????

  5. #5
    jdashm is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2016
    Posts
    58
    Thanks for the response. It looks like that worked.
    And yes I put an underscore (_) in front of the form name so that it would display at the top of the forms object list.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Glad you got it sorted out.

    Didn't think Access would allow an underscore as the first character (but I never tried it ). Good to know.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 07-09-2015, 01:39 AM
  2. Replies: 4
    Last Post: 06-30-2014, 02:53 PM
  3. Replies: 9
    Last Post: 04-18-2014, 08:51 PM
  4. Replies: 2
    Last Post: 04-09-2013, 02:37 AM
  5. DlookUp Function.
    By cap.zadi in forum Forms
    Replies: 11
    Last Post: 09-22-2011, 12:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums