I'm stuggling with how to know what the user pressed with the vbOKCancel message box. I thought that vbOK was 1 and vbCancel was 2, but no matter what I select 1 is always the value.
Private Sub GetDataBtn_Click()
If Saved = 1 Then
On Error GoTo Err_GetDataBtn_Click
DoCmd.SetWarnings False
Dim stDocName1 As String
stDocName1 = "DeleteTempRefundRecord"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.Close acForm, "RefundableForm"
DoCmd.OpenForm "CriteriaForm"
Else
MsgBox "Click Cancel to save the record or OK to continue without saving", vbOKCancel, "Record was NOT saved"
If vbOK = 1 Then (Always hits this line because vbOK = 1, what is the value when pushing the OK button?)
DoCmd.SetWarnings False
Dim stDocName2 As String
stDocName2 = "DeleteTempRefundRecord"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.Close acForm, "RefundableForm"
DoCmd.OpenForm "CriteriaForm"
Else ' If vbCancel is selected
GoTo 1: ' Stop
End If
End If
Exit_GetDataBtn_Click:
Exit Sub
Err_GetDataBtn_Click:
MsgBox Err.Description
Resume Exit_GetDataBtn_Click
1
End Sub
Private Sub GetDataBtn_Click()
If Saved = 1 Then
On Error GoTo Err_GetDataBtn_Click
DoCmd.SetWarnings False
Dim stDocName1 As String
stDocName1 = "DeleteTempRefundRecord"
DoCmd.OpenQuery stDocName1, acNormal, acEdit
DoCmd.Close acForm, "RefundableForm"
DoCmd.OpenForm "CriteriaForm"
Else
MsgBox "Click Cancel to save the record or OK to continue without saving", vbOKCancel, "Record was NOT saved"
If vbOK = 1 Then (Always hits this line because vbOK = 1, what is the value when pushing the OK button?)
DoCmd.SetWarnings False
Dim stDocName2 As String
stDocName2 = "DeleteTempRefundRecord"
DoCmd.OpenQuery stDocName2, acNormal, acEdit
DoCmd.Close acForm, "RefundableForm"
DoCmd.OpenForm "CriteriaForm"
Else ' If vbCancel is selected
GoTo 1: ' Stop
End If
End If
Exit_GetDataBtn_Click:
Exit Sub
Err_GetDataBtn_Click:
MsgBox Err.Description
Resume Exit_GetDataBtn_Click
1
End Sub