wordpress statistics
  • Today is Tuesday, May 22, 2012

4 Responses to “Link External Tables with VBA”

  1. Anonymous says:

    Excellent. Thanks for posting this. Very helpful to me. Tom in Minneapolis.

  2. Anonymous says:

    THANK YOU! This sentence resolved a lot of frustration: “The $ symbol is necessary with the (Excel) Worksheet name.” Much appreciated.

  3. Anonymous says:

    I linked a table to an Excel spreadsheet. Then when the Excel spreadsheet is changed, an Access query/macro updates the table (update query). However, when creating the same spreadsheet (basically a new Excel speadsheet because the values are different) and running the query/macro again which updates the table again, all the values of the previous changes are wiped out. How can I keep the previous changes or replace the previous values when the unique ID is the same? Should I name each Excel spreadsheet a different name each time?

  4. When you Link an Excel Worksheet with specific Sheet Name (or a Named Range) from a WorkBook MS-Access looks for this specific names for maintaining the link correctly. Even if you replace it with a different Workbook with the same Worksheet Name, Workbook Name and earlier data structure but with fresh data the link to access remains intact. You can even copy and paste the data into the earlier worksheet area replacing old data. You don't have to change the name of the worksheet/workbook etc.

    Now the Question of updating data on the table. Here there is something not clear to me from what you have stated above. If you are trying to update only certain records of the table while leaving others, which were updated last time untouched, then you have to device a method to identify records for updating into the table and to leave others untouched.

    For example: You can introduce a Date field in the Access Table and update this field with the current date while updating data from excel table. Next time you can setup criteria to exclude these records based on the last update date and update others etc.

    In either case it is better to create a Make-Table Query, to create a copy of the Access Table (Backup), and add it to the Macro before the update Query line. So that if you find that something went wrong then you can restore the data from this copy of the Table.

    You may create Queries on Linked Excel Table and on Access Table on UniqueIDs (as you have stated) and link them in a common query on UniqueID and check the output records or count of records through VBA (=DCount("*","QueryName") to check whether any matching records are there in both tables which likely to overwrite the earlier updated values before actually running the update Query.

    Regards,
    a.p.r. pillai

Trackbacks/Pingbacks

  1. Urgent: SQL Append Query Syntax

Leave a Reply

You must be logged in to post a comment.