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!

Clearing Tables

Status
Not open for further replies.

Bennie47250

Programmer
Nov 8, 2001
515
US
Prior to repopulating a number of tables with current data, I must first clear the tables of the data from the last processing. I was using delete queries but sometimes data was left in the tables as the field I selected to use as the delete criteria may not have data in it.

I switched to the 4 prong approach of, in a macro, to open the table, use the Run SelectAllRecords, Delete Records, and then close the table.

1) Is there a better method to clearing out the tables?
2) When the macro is running these commands to clear the tables, the screen is flickering as the tables open, select, delete and close. Is there a way to prevent the flickering?

At the beginning of the macro I have used the command ECHO and set it to no, but I don’t see any change in the flickering. (I’m also using the SetWarnings command at the beginning of the macro.

Thanks
Bennie
 
I think the delete query was a good idea. Just drag the * from the table into the grid. Your query, in SQL view, should look something like:
Delete * From tblTable
 
A VBA way:
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE FROM yourTable"
DoCmd.SetWarnings True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or as an alternative to PHV's suggestion:

CurrentDB.Execute "DELETE * FROM <TableName>;", dbFailOnError

Less lines of code.... :)

Ed Metcalfe.

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top