Putting a Delete Query on a Form button

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?
 
F

fredg

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.
 

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