Skip Form_Before_Update

kbreiss

Registered User.
Local time
Today, 18:35
Joined
Oct 1, 2002
Messages
228
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
 
Last edited:
All of my fields are bound EXCEPT my username field which I get from a module. So I was thinking that and insert statement was the only way to get the username into the record. I tried doing the DoCmd.RunCommand acCmdSaveRecord then doing an update statement so I could insert the username but nothing is saving. Do you have any suggestions? I also am receiving a "The command or action "Save Record" isn't available now.

Thanks,
Kacy
________
Paxil settlements
 
Last edited:

Users who are viewing this thread

Back
Top Bottom