- Local time
- Today, 07:47
- Joined
- Feb 19, 2002
- Messages
- 47,233
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:
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?
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?