Hi All
I have a situation that has been driving me absolutely mental that I hope someone can help me with.
This is a simple procedure. I have a form that loads pre-filled with some information on it like a textbox with the current date and 3 other text boxes that load disabled and have contact information in them that cannot be changed.
I am aware how access forms are and I know that the system does not create a new record till the user starts typing in the form.
I want the user to be able to click the close button and get prompted that they are about to lose inforrmation if the proceed to click yes. If the user clicks no, nothing happens and the user is left with the form still opening.
My forms are linked to SQL server tables.
I have tried inputting the following codes for the following scenarios.
me.dirty doesn't seem to call properly i guess because my form opens preloaded with information on it.
the unload event is not calling right either and I am finding that these "empty" records (ie records with no new information on them apart from the pre exsisting data is being written to the table which is completely against what i want
can some please help with this.
Thanks
I have a situation that has been driving me absolutely mental that I hope someone can help me with.
This is a simple procedure. I have a form that loads pre-filled with some information on it like a textbox with the current date and 3 other text boxes that load disabled and have contact information in them that cannot be changed.
I am aware how access forms are and I know that the system does not create a new record till the user starts typing in the form.
I want the user to be able to click the close button and get prompted that they are about to lose inforrmation if the proceed to click yes. If the user clicks no, nothing happens and the user is left with the form still opening.
My forms are linked to SQL server tables.
I have tried inputting the following codes for the following scenarios.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True Or Me.NewRecord Then
If MsgBox("All unsaved data will be lost, are you sure you wish to close", vbExclamation + vbYesNo, "Form Close Warning") = vbYes Then
Me.Undo
Else
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("All unsaved data will be lost, are you sure you wish to close", vbExclamation + vbYesNo, "Form Close Warning") = vbYes Then
If Me.Dirty = True Then
Me.Undo
Cancel = False
End If
End If
End Sub
me.dirty doesn't seem to call properly i guess because my form opens preloaded with information on it.
the unload event is not calling right either and I am finding that these "empty" records (ie records with no new information on them apart from the pre exsisting data is being written to the table which is completely against what i want
can some please help with this.
Thanks