Consulting

Results 1 to 2 of 2

Thread: Continuing trouble with LEFT JOINs

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    Continuing trouble with LEFT JOINs

    Two tables:
    KeyTable, has one column called LKey,
    ParsedTable has one column called RightKey
    Neither table is empty.
    I want to add to Keytable those records in ParsedTable that are NOT in KeyTable.

    I(Try) use
    INSERT INTO KeyTable SELECT ParsedTable.RightKey FROM ParsedTable
    LEFT JOIN KeyTable ON
    ParsedTable.RightKey = KeyTable.LKey WHERE KeyTable.LKey IS NULL.

    ACCESS DoCmd.RunSql insists it can't find RightKey
    An ACCESS FORM has no trouble.

    The sample given to me in an earlier answer works, but I just can't seem to translate it to my needs.

    I'm about to punt, and use something that makes sense, like VBA, opening two recordsets, and comparing them.

  2. #2
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    Two tables:
    KeyTable, has one column called LKey,
    ParsedTable has one column called RightKey
    Neither table is empty.
    I want to add to Keytable those records in ParsedTable that are NOT in KeyTable.

    Try this:

    [VBA]
    DoCmd.RunSQL "INSERT INTO KeyTable " & _
    "SELECT ParsedTable.RightKey " & _
    "FROM ParsedTable " & _
    "WHERE ParsedTable.RightKey NOT IN " & _
    "(SELECT KeyTable.LKey FROM KeyTable)"
    [/VBA]
    Regards,

    Patrick

    I wept for myself because I had no PivotTable.

    Then I met a man who had no AutoFilter.

    Microsoft MVP for Excel, 2007 & 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •