• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

Help with importing data, VB code to delete old table and replace with the new import.

Hi Experts,

Today I would like to know how I could write a little bit of code so when you push a button in MS Access on a form, it will...

1) Delete the a table called "SSL"
2) Import an excel file from, lets say in the root (C:\>SSL.xls )  into a table to replace the 1 we've just deleted called "SSL"
3) I'd like the database to keep all it's relationships.

I need to do this because the information is constantly being updated.  I'd like to use the link to *.xls but se MS Access isn't so great at guessing mulitple assigned fields, import is the easiest method I think.

Thanks Everybody
1 Solution
If you don't want to link then why not just delete the existing data and import the new data.

query to delete...

Delete * from ssl

command to import:

docmd.TransferSpreadsheet acImport,acSpreadsheetTypeExcel9,"SSL","c:\ssl.xls",True

You don't have to worry abolut realtionships in this case.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now