delete records problem

gbshahaq

Sham
Local time
Today, 21:57
Joined
Apr 21, 2004
Messages
52
i have some code to empty a table before importing new data to it.
Code:
DoCmd.OpenTable "Temp_Targets", acViewNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close acTable, "Temp_Targets"


how do I conditionally delete, depending on whether the table is already empty?
i looked at using "if
.recordcount > 0 then" but this did not do anything for me....

pls help!

Sham
 
Your method is longwinded and unnecessary.

Create a delete query

and then:

Code:
DoCmd.SetWarnings False
DoCmd.OpenQuery "YourQuery"
DoCmd.SetWarnings True

Absolutely no need to open the table and then close it.
 
i had a feeling i'd gone in a roundabout fashion - thanks for getting me straightened out!!!

Sham
 
I'd actually advocate my suggestion here though - much better.
 

Users who are viewing this thread

Back
Top Bottom