Delete Query run on button click

G

Guest

I am setting up a master menu for the data entry clerk to simply to have
queryies run to filter our data and appened it to a table. After this step
is completed, I have a delete query to clear out the first table so that the
next set of inventory can be entered. The command buttons on the form do not
find my delete query. I went into the code screen and replaced the name of
my append query (2nd button on form) to the delete query. I have the name
correct, but an error appears saying it can not find the query.

Is a macro better for this step?
 
G

Guest

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stDocName As String

stDocName = "DELETE REPACK DETAIL TABLE QUERY"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command2_Click:
Exit Sub
 
D

Douglas J. Steele

I have no problem making that code work for me.

Are you certain you've got the name of the query typed correctly?

Incidentally, I'd recommend using:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

CurrentDb.QueyDefs("DELETE REPACK DETAIL TABLE QUERY").Execute
dbFailOnError

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Command2_Click

End Sub
 

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