Results 1 to 3 of 3
  1. #1
    onlylonely is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2017
    Posts
    110

    Dlookup issue

    Hi All,

    I'm facing an issue on Dlookup. Hopefully someone can help me out of this.

    Code:
     A = DLookup("dept", "Logintbl", Me.txtresp)
    
    MsgBox (A) << ' Output is QA
    
    
    B = DLookup("EID", "Logintbl", "dept = A") 
    
    
    MsgBox (B)
    I need msgbox B to show up the EID that the dept is QA but it failed. Something to do with "dept = A" but i'm not sure where.

    Thank You

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try

    Code:
    Dim A as String
    Dim B As String
    
    'You are missing the criteria field name
     A = DLookup("dept", "Logintbl", "SomeTEXTField = '" & Me.txtresp & "'")
    ' change SomeTEXTField to the name of the field you want match
    
    MsgBox (A)
    
    
    
    'Missing delimiters around the A ...... delimiters are required because it is a text value
    'and you need to concatenate the variable  
    B = DLookup("EID", "Logintbl", "dept = '" & A & "'")
    
    MsgBox (B)


    EDIT: I misread what you are trying to do. .... I edited the code

  3. #3
    onlylonely is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2017
    Posts
    110
    Quote Originally Posted by ssanfu View Post
    Try

    Code:
    Dim A as String
    Dim B As String
    
    'You are missing the criteria field name
     A = DLookup("dept", "Logintbl", "SomeTEXTField = '" & Me.txtresp & "'")
    ' change SomeTEXTField to the name of the field you want match
    
    MsgBox (A)
    
    
    
    'Missing delimiters around the A ...... delimiters are required because it is a text value
    'and you need to concatenate the variable  
    B = DLookup("EID", "Logintbl", "dept = '" & A & "'")
    
    MsgBox (B)


    EDIT: I misread what you are trying to do. .... I edited the code
    Thanks ssanfu!! Appreciate your help on this.

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

Similar Threads

  1. VBA, DLookup issue
    By jtm013 in forum Programming
    Replies: 6
    Last Post: 03-06-2015, 03:14 PM
  2. DLookup Issue
    By sdel_nevo in forum Programming
    Replies: 10
    Last Post: 05-18-2013, 08:51 AM
  3. DLookup issue
    By Alex Motilal in forum Programming
    Replies: 7
    Last Post: 04-17-2013, 12:41 PM
  4. Dlookup issue
    By Gilgamesh in forum Forms
    Replies: 5
    Last Post: 12-22-2012, 10:26 PM
  5. Dlookup issue
    By brharrii in forum Programming
    Replies: 3
    Last Post: 06-22-2012, 07:08 PM

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