Check Close button pressed

John M

Registered User.
Local time
Today, 23:14
Joined
Nov 20, 2001
Messages
69
Merry Christmas!!

For field validation I an using the before update event to trap for errors. On the form I have a close button which should rollback changes and close the form. I am finding that when I press this close button the before update event of the field is activated and because there is an error I am not allowed to close the form. The obvious workround would be to delete the field and press close again. Please advise.
 
Post the code you are using with your Close Button. Do you want to give a choice to fix the entry or undo all changes and close without saving the entry?

RDH
 
Dear R. Hicks,

Here is the code in the close button:
Private Sub btnClose_Click()
UndoMain Me, "tblBookInformation Temp"
DoCmd.Close

Here is the code in field with validation:
Private Sub Book_ID_BeforeUpdate(Cancel As Integer)
Dim sBook As Variant
Dim sCriteria As String

sCriteria = "[Book_ID] = '" & Me.Book_ID & "'" & " AND [BookType] = '" & Me.Combo67 & "'"
sBook = DLookup("[Book_ID]", "tblBookInformation", sCriteria)

If Not IsNull(sBook) Then
MsgBox "Book ID duplicate - update existing record"
Cancel = True
End If
End Sub

I want to Ask them are they sure and then if yes close the window without saving.

Thanks in advance
 
!!HELP Me. Has anyone encountered this problem before.
 
Try looking at the help file for msgbox function, you can specify a YESNO msgbox. If yes then look at the help file for dirty, this may help canceling the record.

hth

John
 

Users who are viewing this thread

Back
Top Bottom