Results 1 to 5 of 5
  1. #1
    agent- is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    45

    DLookup with multiple field condition


    Hello,

    I am trying to do a Dlookup to output a column, from a table, and have a concatenation of two fields to equal a field on my form. This is my logic:

    Me.Email.Value = DLookup("Email", "tblAuthor_Info", "[Author_Fname] & ' ' & [Author_LName] = " & Forms![Submit_RFP]!Author.Value)

    It keeps getting an error. I need to add first name + last name to equal the author on my form. Any way to fix this or is not possible?

    Thanks!

  2. #2
    agent- is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    45
    nevermind solved

  3. #3
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    It should be:
    Code:
    Me.Email.Value = DLookup("Email", "tblAuthor_Info", "[Author_Fname] = " & Chr(34) & Left(Forms![Submit_RFP]!Author, Instr(1, Forms![Submit_RFP]!Author, " ") -1) & Chr(34) & " AND [Author_LName] = " & Chr(34) & Mid(Forms![Submit_RFP]!Author, Instr(1, Forms![Submit_RFP]!Author, " ") +1) & Chr(34))
    Here's the same but formatted here a different way to be easier to look at:

    Code:
    Me.Email.Value = DLookup("Email", "tblAuthor_Info", "[Author_Fname] = " & Chr(34) & _
    Left(Forms![Submit_RFP]!Author, Instr(1, Forms![Submit_RFP]!Author, " ") -1) & _
    Chr(34) & " AND [Author_LName] = " & Chr(34) & _
    Mid(Forms![Submit_RFP]!Author, Instr(1, Forms![Submit_RFP]!Author, " ") +1) & Chr(34))

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by agent- View Post
    nevermind solved
    Guess I wasn't fast enough

  5. #5
    agent- is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    45
    Thanks Bob for looking into it also. Your response was just a few minutes late haha. I was actually able to do it without the logic to find beg/end of author fname/lname. It was very similar to:

    Me.Email.Value = DLookup("Email", "tblAuthor_Info", "'[Author_Fname] & ' ' & [Author_LName] = '" & Forms![Submit_RFP]!Author.Value)

    I'll have to check on my laptop.

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

Similar Threads

  1. Replies: 2
    Last Post: 07-07-2011, 08:25 AM
  2. Multiple criteria in DLookup
    By crowegreg in forum Forms
    Replies: 7
    Last Post: 06-22-2011, 01:47 AM
  3. Printing multiple reports at once based on condition
    By justinwright in forum Reports
    Replies: 24
    Last Post: 04-13-2011, 01:40 PM
  4. Replies: 6
    Last Post: 12-01-2010, 06:52 PM
  5. Replies: 5
    Last Post: 06-19-2010, 07:55 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