View Full Version : Help!!!!! My cancel button dosen't work!


Sohaila Taravati
10-29-2001, 10:13 AM
I am trying to clear the field when I click my cancel button, but it's not doing it. What am I doing wrong? Here is my code:

Private Sub BL_BeforeUpdate(Cance As Integer)
If (Not IsNull(DLookup("[BL]", "Tracking", "[BL] = '" & Me!BL & "'"))) Then
Select Case MsgBox("The BL # you entered already exists. Choose OK to go to Edit, or Cancel to terminate this action", vbOK + vbCritical, "Duplicate BL Number")
Case vbOK
Cancel = False
BL.Undo

DoCmd.OpenForm "Main Form", acNormal, , "[BL]= Forms![Main Form1]![BL]"

Case vbCancel

Exit Sub
End Select
End If
End Sub

Rich
10-29-2001, 12:47 PM
Your logic doesn't appear correct if they click OK you undo the record but not if they click cancel. Since you want the record removed then just use Me.Undo anyway just ask if they want to edit.