Can someone please help me with the code that will enable me to clear all of the data within a table (leaving the column headers) by clicking a form button. I'm ok with setting up the button, just need the code now.
Thanks!
Josh
Can someone please help me with the code that will enable me to clear all of the data within a table (leaving the column headers) by clicking a form button. I'm ok with setting up the button, just need the code now.
Thanks!
Josh
CurrentDb.Execute "DELETE * FROM TableName"
Hey Paul - thanks for the quick reply. I'm using the code below & the Table opens, but the data doesn't delete. Any idea what I'm doing wrong?
Private Sub ClearElementTables_Click()
'Clear Element Tables
DoCmd.SetWarnings False
CurrentDb.Execute "DELETE * FROM Comm_Loan_Data"
DoCmd.SetWarnings True
End Sub
Thanks!
Josh
That shouldn't open the table, just delete all its records. Is the table already open?
SetWarnings not needed with Execute method.
The * wildcard is also not need but should not hurt. Fields do not need to be referenced because the entire record is deleted.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Try:
CurrentDb.Execute "DELETE FROM Comm_Loan_Data"