J
Jonathan Snyder via AccessMonster.com
Hi all,
I'm using a before update event to validate data entered on a form. If
data is valid my code works fine. If data is invalid I want the event
canceled and what ever was entered erased. My code works fine up through
the msgbox, but then the data is not erased and a default message appears
saying a validation rule has been violated. I have no validation rules
attached to the table or form other than this code. I dont understand why
the cancel=true and me.undo statements are not working.
Please help!!
Private Sub Trip_ID_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Trip_ID_BeforeUpdate
Dim trip As String
Dim vill As String
Dim strvill As String
Dim strtrip As String
vill = Me.Village
strvill = Left(vill, 1)
trip = Me.Trip_ID
strtrip = Left(trip, 1)
If strtrip <> strvill Then
MsgBox "Your Trip ID must begin with the first letter of the
village name", vbOKOnly, "Hey Dude"
Cancel = True
Me.Trip_ID.Undo
End If
I'm using a before update event to validate data entered on a form. If
data is valid my code works fine. If data is invalid I want the event
canceled and what ever was entered erased. My code works fine up through
the msgbox, but then the data is not erased and a default message appears
saying a validation rule has been violated. I have no validation rules
attached to the table or form other than this code. I dont understand why
the cancel=true and me.undo statements are not working.
Please help!!
Private Sub Trip_ID_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Trip_ID_BeforeUpdate
Dim trip As String
Dim vill As String
Dim strvill As String
Dim strtrip As String
vill = Me.Village
strvill = Left(vill, 1)
trip = Me.Trip_ID
strtrip = Left(trip, 1)
If strtrip <> strvill Then
MsgBox "Your Trip ID must begin with the first letter of the
village name", vbOKOnly, "Hey Dude"
Cancel = True
Me.Trip_ID.Undo
End If