Guest_imported
New member
- Jan 1, 1970
- 0
Okay, I'm a Newbie and I'm stuck. I have a computer equipment inventory DB with multiple tables. When an older computer is replaced it is moved from a current inventory table to a retired table until it is donated or disposed of. To automate this process I built an append query and a delete query. The Append query copies the selected records from the current table to the retired table and then the delete query deletes the selected records from the current table. If each query is run separately they work fine. I'm trying to run both queries in VBA from a command button, but can't seem to get it to work. I get an error saying "Access cant find the object qryDelete" (the delete query). Any help is greatly appreciated. Here's the code:
Private Sub cmdRetire_Click()
On Error GoTo Err_cmdRetire_Click
Dim stDocName As String
DoCmd.SetWarnings False
stDocName = "qryAppend"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocName = "qryDelete"
DoCmd.OpenTable stDocName, acViewNormal, acEdit
DoCmd.SetWarnings True
Exit_cmdRetire_Click:
Exit Sub
Err_cmdRetire_Click:
MsgBox Err.Description
Resume Exit_cmdRetire_Click
End Sub
Thanks, VBA Guy
Private Sub cmdRetire_Click()
On Error GoTo Err_cmdRetire_Click
Dim stDocName As String
DoCmd.SetWarnings False
stDocName = "qryAppend"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocName = "qryDelete"
DoCmd.OpenTable stDocName, acViewNormal, acEdit
DoCmd.SetWarnings True
Exit_cmdRetire_Click:
Exit Sub
Err_cmdRetire_Click:
MsgBox Err.Description
Resume Exit_cmdRetire_Click
End Sub
Thanks, VBA Guy