Delete Query on Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I cannot seem to add a command button on a form that supports the Delete
Query function. Is this possible?
 
The Delete Query function? You mean you want to run a delete query by
clicking a button on the form?

Assuming that this is indeed what you want to do, use code similar to this
for the Click event of the button:

Private Sub CommandButtonName_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "DeleteQueryName"
DoCmd.SetWarnings True
End Sub
 
Thanks so much!

Ken Snell said:
The Delete Query function? You mean you want to run a delete query by
clicking a button on the form?

Assuming that this is indeed what you want to do, use code similar to this
for the Click event of the button:

Private Sub CommandButtonName_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "DeleteQueryName"
DoCmd.SetWarnings True
End Sub
 
Follow up Question

Hello,

I'm looking to do something similar to this process. I have a table that houses historical data (let's call it "History"). It's got an agent's name, call event, and date & time of the event. I want to be able to pull up a form, enter in a start and end date, and click okay and run a Delete Query to purge records in the "History" table that fall between that date. Is that possible? (Sort of like marrying the "Query by Form" process and "Delete Query".
 
Back
Top