Hi, Originally, I put 2 command buttons which move 2 types of records to 2 separate tables.
Now, I combine these 2 command buttons as one, and it has 2 selections, yes/no.
If the user select Yes to move completed records, it works, but if they select No to move archive records, the error message reads: The action or method require a Query Name argument. Where did I do wrong? Thanks.
Private Sub Command193_Click()
On Error GoTo Err_Command193_Click
Dim stDocName, iss, Reply As String
Reply = MsgBox("Are you moving Completed Records? ", 36, "Which Move")
If Reply = 6 Then
' Private Sub MoveToArchive_Click()
' On Error GoTo Err_MoveToArchive_Click
Dim stDocName1 As String
Dim stDocName2 As String
If DCount("*", "[certStatus]", "Status Like '*completed*'") = 0 Then
MsgBox ("No more completed record to move.")
Exit Sub
End If
stDocName1 = "append_to_archive"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
stDocName2 = "delete_completed_records"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
Exit_MoveToArchive_Click:
Exit Sub
Err_MoveToArchive_Click:
MsgBox Err.Description
Resume Exit_MoveToArchive_Click
Exit Sub
Else
' Private Sub MoveToInactive_Click()
' On Error GoTo Err_MoveToInactive_Click
Dim stDocName3 As String
Dim stDocName4 As String
If DCount("*", "[certStatus]", "Status Like '*inactive*'") = 0 Then
MsgBox ("No more inactive record to move.")
Exit Sub
End If
stDocName3 = "append to inActive"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
stDocName4 = "delete inActive"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
Exit_MoveToInactive_Click:
Exit Sub
Err_MoveToInactive_Click:
MsgBox Err.Description
Resume Exit_MoveToInactive_Click
Exit Sub
End If
Exit_Command193_Click:
Exit Sub
Err_Command193_Click:
MsgBox Err.Description
Resume Exit_Command193_Click
End Sub
Now, I combine these 2 command buttons as one, and it has 2 selections, yes/no.
If the user select Yes to move completed records, it works, but if they select No to move archive records, the error message reads: The action or method require a Query Name argument. Where did I do wrong? Thanks.
Private Sub Command193_Click()
On Error GoTo Err_Command193_Click
Dim stDocName, iss, Reply As String
Reply = MsgBox("Are you moving Completed Records? ", 36, "Which Move")
If Reply = 6 Then
' Private Sub MoveToArchive_Click()
' On Error GoTo Err_MoveToArchive_Click
Dim stDocName1 As String
Dim stDocName2 As String
If DCount("*", "[certStatus]", "Status Like '*completed*'") = 0 Then
MsgBox ("No more completed record to move.")
Exit Sub
End If
stDocName1 = "append_to_archive"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
stDocName2 = "delete_completed_records"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
Exit_MoveToArchive_Click:
Exit Sub
Err_MoveToArchive_Click:
MsgBox Err.Description
Resume Exit_MoveToArchive_Click
Exit Sub
Else
' Private Sub MoveToInactive_Click()
' On Error GoTo Err_MoveToInactive_Click
Dim stDocName3 As String
Dim stDocName4 As String
If DCount("*", "[certStatus]", "Status Like '*inactive*'") = 0 Then
MsgBox ("No more inactive record to move.")
Exit Sub
End If
stDocName3 = "append to inActive"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
stDocName4 = "delete inActive"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
Exit_MoveToInactive_Click:
Exit Sub
Err_MoveToInactive_Click:
MsgBox Err.Description
Resume Exit_MoveToInactive_Click
Exit Sub
End If
Exit_Command193_Click:
Exit Sub
Err_Command193_Click:
MsgBox Err.Description
Resume Exit_Command193_Click
End Sub