Results 1 to 3 of 3
  1. #1
    waynemurry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    3

    Query to Lookup 2 fields on each record. Trouble with Dlookup and Joins

    Here is the setup:



    Table 1 : Each record has 2 stock symbols as follows:

    Symbol 1 Symbol 2
    IBM GE
    AAPL GOOG
    GOOG GE

    Table 2 : Each record consists of 1 stock symbol along with a yield as follows:

    Symbol Yield
    IBM 3.0%
    GOOG 2.0%
    AAPL 3.5%
    GE 3.75%
    PG 4.0%
    KFT 3.2%

    Please notice that Table 2 has more names than Table 1. I am looking for the final result to look like:

    Symbol 1 Yield Symbol 2 Yield
    IBM 3.0% GE 3.75%
    AAPL 3.5% GOOG 2.0%
    GOOG 2.0% GE 3.75%

    In the query I have built, I have:

    Field 1 = Symbol 1 from Table 1
    Field 2 = DLookUp([Table 2]![Symbol],"Table 2",[Table 2]![Symbol]=[Table 1]![Symbol 1])
    Field 3 = Symbol 2 from Table 1
    Field 4 = DLookUp([Table 2]![Symbol],"Table 2",[Table 2]![Symbol]=[Table 1]![Symbol 2])

    I have attempted several joins, but nothing seems to work because of the 2 fields on the same record from Table 1. Not joining at all, of course, gives me all of the records with plenty of nulls. All I am looking to replicate is the vlookup function from Excel. I feel like the solution is probably very simple, however I have found it difficult to describe the problem in a Google search. Thus my question in this forum.

    Any help would be greatly appreciated.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Try:

    Field 2 = DLookUp("[Yield]","Table 2","[Symbol]='" & [Symbol 1] & "'")
    Field 4 = DLookUp("[Yield]","Table 2","[Symbol]='" & [Symbol 2] & "'")

    Advise no spaces, special character/punctuation (underscore is exception) in names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    waynemurry is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    3
    That was a huge help. It worked. Thanks.

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

Similar Threads

  1. Help with Access - Having trouble with joins
    By steelcurtain11 in forum Access
    Replies: 2
    Last Post: 02-07-2013, 01:41 AM
  2. Replies: 1
    Last Post: 01-31-2013, 04:56 AM
  3. Replies: 9
    Last Post: 08-31-2012, 12:00 PM
  4. Replies: 1
    Last Post: 05-30-2011, 06:03 PM
  5. Replies: 5
    Last Post: 06-29-2010, 01:24 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