Replacing Tables

B

BWolf

Here is the situation:

I have a front-end and back-end to a database that I maintain. I want
to leave the database up to someone else and I want to automate the
daily updates that I do so that its minimal work. Can I write a macro
(or VBA code) that would do these steps:

1. Delete old tables
2. Import tables (xls)
3. Define primary keys (some talbes have multiple keys)
4. Recreate relationships

Is this possible?

Thanks for any help
Brad
 
K

KARL DEWEY

Probably the easier thing to do is to link the Excel files and build macro to
update your tables.
 
B

BWolf

I thought about this, but the excel files are created daily, so this is
just as much work as doing it all manually.
 
T

Tim Ferguson

1. Delete old tables

No: just empty them. Vis

DELETE FROM oldTable WHERE TRUE;

(the Where True is not necessary, but is a reminder that this is a very
destructive operation!)
2. Import tables (xls)

Just run an append query into the empty tables

INSERT INTO oldTable (OneField, TwoField, ThreeField)
SELECT FieldOne, FieldTwo, FieldThree
FROM [Sheet1$] IN "" [excel5.0;database="\\server\drive\database.xls"

(the IN clause syntax is taken from memory: you'll have to check the
appropriate strings for your own needs. It's all documented in the help
files.)
3. Define primary keys (some talbes have multiple keys)

Don't need to if you don't destroy the tables in the firsst place
4. Recreate relationships

Ditto


Hope that helps



Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top