Dlookup in a query or vba

Posted on 2011-05-06
Last Modified: 2012-05-11
I think this is a pretty remedial question but it is doing my head in...  I have two tables I have a contacts table with a unique identifier called Contact_Id.  I use that in other tables.  Now, I am trying to do a dlookup to send a subject line for Outlook and the dlookup is returning the first value in the contacts table for all records.

dim Employ as string

What I have is  Employ = DLookup("[firstname]", "tbl_contacts", "[contact_id] = contact_id")

The query it is referencing is another table that has the contact_ID in it.  What I want is the unique first name of each contact is returned.  What I am getting is the first name in the table being returned for all records.  The Contact_ID is a number.


Question by:mtrussell
    LVL 22

    Accepted Solution

    You need to do something like:
    DLookup("[firstname]", "tbl_contacts", "[contact_id] = " & contact_id)


    Author Closing Comment


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now