+ Reply to Thread
Results 1 to 4 of 4

Updating/Adding Access Database Records from Linked Table

  1. #1
    Registered User
    Join Date
    10-04-2009
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    77

    Question Updating/Adding Access Database Records from Linked Table

    Hi All,

    I was wondering if anyone might be able to help me with a solution for this.

    I have an Excel/Access system that I've created for work. I work in the motor insurance industry and we receive a weekly submission from one of our suppliers which can contain new records and updates to existing records.
    I paste all of the data into a Linked Table (lets call it MyLinkedTable for example) and so that table automatically updates in to Access.

    I need help with an SQL query to loop through the entries in MyLinkedTable and if they already exist (using the CaseRef field as a unique identifier) then the data for that row in MyTable is overwritten by the data in MyLinkedTable.
    If it doesn't exist in MyTable, then it appends it to the MyTable table.


    MyLinkedTable and MyTable structure - both identical
    - ID
    - CaseRef
    - PH_Name
    - UpdateDate
    - CaseStatus
    - DateLitigated
    - HandlerName
    - HandlerEmail
    - ManagerName
    - ManagerEmail

    I can do the update query without an issue:

    Please Login or Register  to view this content.
    What I can't work out is how to make it check to see if the CaseRef already exists in MyTable and if it doesn't, then to add it as a new row. Any help would be greatly appreciated.

    Many Thanks
    Last edited by Smurlos; 02-20-2024 at 04:37 AM. Reason: Change title

  2. #2
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    98

    Re: Updating/Adding Access Database Records from Linked Table

    Insert Into MyTable (the field list)
    Select (field list) from MyLinkedTable where not CaseRef in (Select CaseRef from MyTable)

    edit: wrong table added to the caseref select at the end

  3. #3
    Registered User
    Join Date
    10-04-2009
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Updating/Adding Access Database Records from Linked Table

    Thanks for the response. It's providing me with a syntax error when I put the code in exactly as you've suggested

    Syntax error (comma) in query expression '(ID,CaseRef,PH_Name,UpdateDate,CaseStatus,DateLitigated,HandlerName,HandlerEmail,ManagerName,ManagerEmail)'
    Any suggestions?

    Many Thanks

  4. #4
    Registered User
    Join Date
    09-18-2023
    Location
    Geogia, USA
    MS-Off Ver
    365
    Posts
    98

    Re: Updating/Adding Access Database Records from Linked Table

    Can you post the entire insert statement you have?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 05-12-2017, 01:34 PM
  2. Linked Access query isn't updating
    By jas. in forum Excel General
    Replies: 4
    Last Post: 06-24-2014, 04:11 PM
  3. Updating Linked Table Database Location (Runtime)
    By split_atom18 in forum Access Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2013, 09:53 AM
  4. Updating multiple records in Access table using excel VBA
    By anthony1312002 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-28-2012, 04:19 PM
  5. Deleting all records in a access database table from Excel
    By Dave31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2008, 02:18 PM
  6. Updating Records from MS Access
    By Andrew Thacker in forum Excel General
    Replies: 1
    Last Post: 03-27-2006, 03:10 AM
  7. Updating records in an Access DB
    By Lucho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2005, 10:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1