button to delete all the records from two tables

R

Roger

Is it possible to create a button in a form that would delete the entire contents of two tables while leaving the tables intact?
And how would I go about creating it?

Thanks,
Roger
 
D

Dirk Goldgar

Roger said:
Is it possible to create a button in a form that would delete the
entire contents of two tables while leaving the tables intact? And
how would I go about creating it?

'----- start of "air" code -----
Private Sub cmdEmptyTables_Click()

Dim db As DAO.Database

If MsgBox("Are you sure you want to do this?", _
vbQuestion+vbYesNo, _
"Empty Tables - Are You Sure?") _
= vbYes _
Then
Set db = CurrentDb
db.Execute "DELETE * FROM Table1", dbFailOnError
db.Execute "DELETE * FROM Table2", dbFailOnError
Set db = Nothing
End If

End Sub
'----- end of "air" code -----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top