Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine 2 command buttons error message 1

Status
Not open for further replies.

hu5

Technical User
Apr 9, 2004
28
US
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
 
Take a look at your code:
stDocName[blue]3[/blue] = "append to inActive"
DoCmd.OpenQuery stDocName[red]1[/red], acNormal, acEdit

stDocName[blue]4[/blue] = "delete inActive"
DoCmd.OpenQuery stDocName[red]2[/red], acNormal, acEdit

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top