Hi,
I use one command button to control 2 queries, after adding all completed records to archive file, it should delete completed records from the original file.
I want to create a prompt message to alert user that there's no more completed records to move when they press the Move button.
The code looks for "...completed...." in the Status field. If it didn't find the letter "completed", the message should pop up immediately when user press Move button.
The following code only came up after it asks the user "Do you want to append....then delete..., you will append 0 record....will delete 0 record....".
Where should I place this code? and is this code only work for the current record listed on the form or for the entire table? Thank you.
Private Sub MoveToArchive_Click()
On Error GoTo Err_MoveToArchive_Click
Dim stDocName1 As String
Dim stDocName2 As String
stDocName1 = "append_to_archive"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
stDocName2 = "delete_completed_records"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
If Me!Status.Value <> ("*" & "completed" & "*") Then
MsgBox ("No more completed record to move.")
End If
Exit_MoveToArchive_Click:
Exit Sub
Err_MoveToArchive_Click:
MsgBox Err.Description
Resume Exit_MoveToArchive_Click
End Sub
I use one command button to control 2 queries, after adding all completed records to archive file, it should delete completed records from the original file.
I want to create a prompt message to alert user that there's no more completed records to move when they press the Move button.
The code looks for "...completed...." in the Status field. If it didn't find the letter "completed", the message should pop up immediately when user press Move button.
The following code only came up after it asks the user "Do you want to append....then delete..., you will append 0 record....will delete 0 record....".
Where should I place this code? and is this code only work for the current record listed on the form or for the entire table? Thank you.
Private Sub MoveToArchive_Click()
On Error GoTo Err_MoveToArchive_Click
Dim stDocName1 As String
Dim stDocName2 As String
stDocName1 = "append_to_archive"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
stDocName2 = "delete_completed_records"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
If Me!Status.Value <> ("*" & "completed" & "*") Then
MsgBox ("No more completed record to move.")
End If
Exit_MoveToArchive_Click:
Exit Sub
Err_MoveToArchive_Click:
MsgBox Err.Description
Resume Exit_MoveToArchive_Click
End Sub