1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Need Help with Dloopup on MS Access

Discussion in 'Software Development' started by GLWEST, Jul 19, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. GLWEST

    GLWEST Thread Starter

    Joined:
    Jul 19, 2007
    Messages:
    3
    I have a table called Office_Names that has a 153 fields. I want to used a Variable in the "Expression" part of the Dlookup.

    For example I have a field called E2003

    If I hardcode xx = DLookup(["E001"], "Office_Name", "[ID] = 3")

    I get my desired value. Now I want to replace "E002" with a variable that contains the name "E002" such as xlName = E002. Microsoft implies that this can be done for the DLookup Expression can be a constanct, a Variable or a Calculation. I just can NOT find the right syntax.
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    I can't follow your example, I am not sure how you get from E2003 to ["E001"] or [ID] to "E002".
    What do you actually want to do with the value when you get it?
     
  3. GLWEST

    GLWEST Thread Starter

    Joined:
    Jul 19, 2007
    Messages:
    3
    Sorry for the confusion. As stated I have 150 fields in my Access table. Some of the field names range from E2001 to E2051. What I want to do is to replace the "expr" part of the Dlookup(expr, domain, Criteria) field with a variable instead of a constant and I can NOT figure out the right string syntax that incorperates a variable for expt, a constant domain and a constant criteria.

    My corrected example I have a field called E2001

    If I hardcode xx = DLookup(["E2001"], "Office_Name", "[ID] = 3")

    I get my desired value. Now I want to replace "E2001" with a variable that contains the name "E2001" such as xlName = E2001.

    I hope that helps
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    This works for me
    name = "[E2001]"
    MsgBox DLookup(name, "[Office_Name]", "[ID] = 3")
     
  5. GLWEST

    GLWEST Thread Starter

    Joined:
    Jul 19, 2007
    Messages:
    3
    It works! Thanks for your help.
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/597797

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice