I want one button to run all 5 delete queries followed by the 3 append queries. I noticed when I originally wrote the code that I got a delete query warning for ALL FIVE delete queries. I think the warning is necessary but I'd like to see it only ONCE. I was feeling frisky so I tried writing my own code to turn off the warnings. Notice how savvy I was to put the code to turn off the warnings after the first query, hoping to get one warning and then no more. (Laugh if you need to.) That didn't work--I got no error messages at all, but hey the code did run as otherwise intended so I'm still on the happy side.
I recognize the best way to do this may be to write my own warning message, ideally with a button you have to click to proceed in the deletion. I just don't know how to make that work so that if the user selects "Proceed" the code fires, and if the user clicks "Cancel" the queries do not run.
Here is the code I tried.
Expand|Select|Wrap|Line Numbers
- Private Sub cmdDeleteAll_Click()
- DoCmd.OpenQuery "Delete Team Selection Records"
- DoCmd.SetWarnings (WarningsOff)
- DoCmd.OpenQuery "Delete Foreman Records"
- DoCmd.OpenQuery "Delete Assignment Records"
- DoCmd.OpenQuery "Delete Equipment Records"
- DoCmd.OpenQuery "Delete Staging Location Records"
- DoCmd.OpenQuery "Append to Team Selection"
- DoCmd.OpenQuery "Append NonTrans to Team Selection"
- DoCmd.OpenQuery "Append to Staging Locations"
- DoCmd.SetWarnings (WarningsOn)
- End Sub