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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all records Command Button 1

Status
Not open for further replies.

progressiverookie

Technical User
Apr 28, 2004
16
0
0
US
Hi,

What is the easiest way to create a user-friendly command button that deletes all records in a specified table? Any help would be appreciated.

Thanks in advance, Jeremy
 
Take a look at the MsgBox function, the DoCmd.SetWarnings method and the DoCmd.RunSQL "DELETE * FROM TableName;" sql instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
progressiverookie

Hopefully, you are not concerned about relationships. Deleting records that are linked can cause chaos.

You can use a DELETE query. Use the Command button wizard to get you started. Perhaps use Record -> Delete record.

Then with the form in design mode and the properties window open (from the menu, "View" -> "Properties"), select the command button on the form, and the select the "Event" tab on the "Properties" window. You will see and Event Procedure for the OnClick event. Click on this field. You will see a command button appear to the right, "...". Click on this command button to open up the coding window. You will see the code Access uses to delete a specific record. Replace it with...

[tt]DoCmd.RunSQL "Delete * From YourTableName"
[/tt]


Richard
 
Thanks Richard

The classic Tek-Tips "What I need, when I need it". Star coming.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top