Export to another Access DB and delete what was exported?

  • Thread starter Thread starter sunilkeswani
  • Start date Start date
S

sunilkeswani

Hi,

I need some help on how I can do this. What I need is some VBA code
which would help me retrieve all records for yesterday which of course
I can query with Date()-1, and then

1) Add these records to a Table1 in another database (Note: Table1
already has records in it)

Then

2) Delete those records from the original database.

Any help would be appreciated.

Cheers
Sunny
 
CurrentDb.Execute "INSERT INTO Table1 " & _
"IN 'C:\Some Folder\SomeFile.mdb' " & _
"SELECT * FROM MyTable " & _
"WHERE MyDate = Date() - 1", dbFailOnError

CurrentDb.Execute "DELETE FROM MyTable " & _
"WHERE MyDate = Date() - 1", dbFailOnError
 
Thanks Doug, I will try this today, hope this will work on a query
based on a linked table as well...

Cheers
Sunny
 
Back
Top