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
squidlingsAsked:
Who is Participating?
 
peter57rConnect With a Mentor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.