Incomplete record saving message

Re: Prevent automatic ms access message when closing unsaved form

You are cancelling the update but that doesn't clear the pending changes. Your code needs to be:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.SectorCombo & vbNullString) = 0 Or Len(Me.StationCombo & vbNullString) = 0 _
Or Len(Me.BuildingCombo & vbNullString) = 0 Or Len(Me.Description & vbNullString) = 0 _
Or Len(Me.Requestor & vbNullString) = 0 Or Len(Me.RequestorPhone & vbNullString) = 0 Then
    MsgBox "You are closing the Work Order Form without submitting; the form will be cleared."
    Cancel = True
    Me.Undo
    Exit Sub
End If

I'm not sure what mSaved is or when it gets set. Are you trying to ask the user if he wants to save invalid data?
 
Re: Prevent automatic ms access message when closing unsaved form

Sorry about the confusion. I didn't mean to paste that. I went too far down on my notepad. The code stopped at the first End If. I tried copying and pasting your code and I'm still getting the same message when I try and exit out of the incomplete form.
 
What exactly is the error message?
Are you sure you pasted the code in the Form's BeforeUpdate event?
Is there a subform that could be producing the error message?
 
See attached for a picture of the error.
 

Attachments

  • 20130312_071931.jpg
    20130312_071931.jpg
    99.8 KB · Views: 107
I actually solved this by removing that code from the before event altogether. Just fyi. Thanks for the help though.
 

Users who are viewing this thread

Back
Top Bottom