Is there away to skip Form_Before_Update? I have a command button (cmdOK) that I use when the user adds a record. My problem is the code runs to add for cmdOK when clicked and then it runs again following immediately. I'm wondering if I could put something in the cmdOK_Click that after it gets done updating it quits running the program and skips the "Form_Before_Update" Any advice would be appreciated.
Private Sub cmdOK_Click()
If cboAction.ListIndex = 1 Then 'save record if add
MsgBox txtFacilityName & " Added."
DoCmd.SetWarnings (False)
DoCmd.Save acForm, "frmFacility"
DoCmd.RunCommand acCmdRefresh
strDocName = "qryAddInfo"
DoCmd.OpenQuery strDocName, acNormal, acEdit
cboAction.Requery
DoCmd.GoToRecord acForm, "frmFacility", acNewRec
'WOULD LIKE SOMETHING HERE THAT STOPS IT FROM RUNNING ANYMORE CODE
End If
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save Changes to " & txtFacilityName & " ?", vbQuestion + vbYesNo, "Save?") = vbYes Then
DoCmd.SetWarnings (False)
If cboAction.ListIndex = 1 Then
strDocName = "qryAddInfo"
DoCmd.OpenQuery strDocName, acNormal, acEdit
Me.Undo 'keeps from getting an error...doesn't try to save the record twice.
End If
Else
Me.Undo
End If
End Sub
________
HERBAL HEALTH SHOP
Private Sub cmdOK_Click()
If cboAction.ListIndex = 1 Then 'save record if add
MsgBox txtFacilityName & " Added."
DoCmd.SetWarnings (False)
DoCmd.Save acForm, "frmFacility"
DoCmd.RunCommand acCmdRefresh
strDocName = "qryAddInfo"
DoCmd.OpenQuery strDocName, acNormal, acEdit
cboAction.Requery
DoCmd.GoToRecord acForm, "frmFacility", acNewRec
'WOULD LIKE SOMETHING HERE THAT STOPS IT FROM RUNNING ANYMORE CODE
End If
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save Changes to " & txtFacilityName & " ?", vbQuestion + vbYesNo, "Save?") = vbYes Then
DoCmd.SetWarnings (False)
If cboAction.ListIndex = 1 Then
strDocName = "qryAddInfo"
DoCmd.OpenQuery strDocName, acNormal, acEdit
Me.Undo 'keeps from getting an error...doesn't try to save the record twice.
End If
Else
Me.Undo
End If
End Sub
________
HERBAL HEALTH SHOP
Last edited: