Putting a Delete Query on a Form button

  • Thread starter Thread starter jobeibi
  • Start date Start date
J

jobeibi

I want to create a button that executes a Delete query,
but Access won't even show my delete queries in the
dropdown box. Is there a way to get around this?
 
I want to create a button that executes a Delete query,
but Access won't even show my delete queries in the
dropdown box. Is there a way to get around this?

Add a command button to the form.
Do NOT use the Wizard.

Display the button's property sheet.
Click on the Events tab.
On the OnClick line write:
[Event Procedure]
Click on the button with the 3 dots that will appear on that line.
When the code window opens, between the two already existing lines,
write:

DoCmd.OpenQuery "QueryName"

Change "QueryName" to the actual name of the query.

Save the changes.

When you click on the command button you will be given a warning
message. If you do not wish the message, then change the above code
to:
DoCmd.SetWarnings False
DoCmd.OpenQuery "QueryName"
DoCmd.SetWarnings True

Good luck.
 
Back
Top