I'm checkling to see if a form's data is Dirty when the user attempts to close the form.
I'm using the following to cancel the closing of the form when the user presses 'Cancel'.
When the user presses 'Yes the form closes and when the user presses 'No' the form closes.
It worked fine in my other db. But now when I press 'Cancel' the form closes where as it didn't in the other db. The only difference is that the other db the form is a split form with no underlying form. The current db the form is popup and model and called from an underlying form. There is other area in the forms module that sets the bPreventClose (Bollean) to true or false.
Not sure if anyone will need the rest of the code, but let me know if you do.
I've changed the form to split and reset the Popup and Model to no but it didn't help.
I'm using the following to cancel the closing of the form when the user presses 'Cancel'.
When the user presses 'Yes the form closes and when the user presses 'No' the form closes.
It worked fine in my other db. But now when I press 'Cancel' the form closes where as it didn't in the other db. The only difference is that the other db the form is a split form with no underlying form. The current db the form is popup and model and called from an underlying form. There is other area in the forms module that sets the bPreventClose (Bollean) to true or false.
Not sure if anyone will need the rest of the code, but let me know if you do.
I've changed the form to split and reset the Popup and Model to no but it didn't help.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim UserResp As Integer
UserResp = MsgBox("Record(s) have been added or changed." & vbCrLf & "Save the changes?", vbYesNoCancel, "Data Manager")
Select Case UserResp
Case vbNo
bPreventClose = False
Me.Undo
Exit Sub
Case vbCancel
bPreventClose = True
Exit Sub
Case Else
bPreventClose = False
End Select
End Sub
Last edited: