Hi all!
I've been away from Access for a long while now, so please bear with me.
I've been searching the FAQ's and threads but cannot seem to find this answer; please pardon me if this has been answered elsewhere and feel free to point me to the correct thread.
I am using this code on an Access 97 database front-end (old, I know - but it still functions well) form, under a command button.
I have only just recently become aware that it allows the DoCmd.PrintOut function to run even if the DoCmd.OpenQuery "BackUpQuery" function fails.
The query would fail if the data entered into the form is already in the table as in "Indexed, (Yes - No Duplicates)".
I am trying to come up with a way to halt the process if the SQL "BackUpQuery" fails.
Something like:
Any help would be appreciated!!
- Turb
I've been away from Access for a long while now, so please bear with me.
I've been searching the FAQ's and threads but cannot seem to find this answer; please pardon me if this has been answered elsewhere and feel free to point me to the correct thread.
I am using this code on an Access 97 database front-end (old, I know - but it still functions well) form, under a command button.
Code:
Private Sub Save_Button_Click()
On Error GoTo Err_Save_Button_Click
Dim strMsg As String
strMsg = "You MUST double check your work." & vbCrLf
strMsg = strMsg & vbCrLf
strMsg = strMsg & "Have you checked the information on the form for correctness?" & vbCrLf
strMsg = strMsg & "Click Yes to continue or No to check your work."
If MsgBox(strMsg, vbQuestion + vbYesNo, "HAVE YOU CHECKED YOUR WORK?") = vbYes Then
DoCmd.OpenQuery "BackUpQuery"
DoCmd.PrintOut acSelection
DoCmd.Close acDefault
DoCmd.RunMacro "Form1_Reopen"
Else
'do nothing
End If
Exit_Save_Button_Click:
Exit Sub
Err_Save_Button_Click:
MsgBox Err.Description
Resume Exit_Save_Button_Click
End Sub
The query would fail if the data entered into the form is already in the table as in "Indexed, (Yes - No Duplicates)".
I am trying to come up with a way to halt the process if the SQL "BackUpQuery" fails.
Something like:
Code:
DoCmd.OpenQuery "BackUpQuery"
If DoCmd.OpenQuery "BackUpQuery" = 0, Then
'do nothing
Any help would be appreciated!!
- Turb