Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA and table contents deletion

Status
Not open for further replies.

Huey462

Technical User
Jun 30, 2010
18
US
I have a saved import to restore the database backup, however when this is run, the database size doubles because the old information was still in there. To prevent this, I would like to use VBA to clear out the table before it is repopulated with the import.

Code:
Private Sub Command4_Click()
' Deletes old information
    StrSQL = "Delete * from Master Table;"
    DoCmd.SetWarnings False
    DoCmd.RunSQL StrSQL
    DoCmd.SetWarnings True
' Imports infomation from pre-defined import
    DoCmd.RunSavedImportExport ("Import Backup")
End Sub
[CODE]

From everything I’ve read, the StrSQL bit should remove the table’s contents, but either I typed something wrong, or left out something.

Any help would be greatly appreciated.

Thanks in advance,

-Huey
 
StrSQL = "Delete * from [!][[/!]Master Table[!]][/!];"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Exactly what I needed =D

Thank you so much

-Huey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top