H
hughess7
In the beforeupdate event of a control I have some code (see below) to check
record does not already exist. It produces an access system error though (see
below). I want it to remove the ReviewDate but leave the rest of the data
hence me.reviewdate.undo - but this does not work.
If I put it in the afterupdate event of the control I don't get the
violation error but the undo still does not work.
I am doing it this way as I want the validation checking for the data to
take place before a save record is performed. That way if the navigation
buttons are pressed I won't get any errors from an unsuccessful save.
Can anyone help with this as I am going round in circles and its doing my
head in...
Thanks
Acess system error produced:
"The value in the field violates a validation rule for the record or
field." "For example you may have changed a validation rule without
verifying whether the existing data matches the new validation rule."
My validation code:
(called from Private Sub ReviewDate_BeforeUpdate(Cancel As Integer))
Jetwhere = "[ReviewDate] = #" & Format$(CheckDate, "mm\/dd\/yyyy") & "#" &
"AND Specialist = " & _
Format(SpecID, "0") & "AND ItineraryID <> " & ItinID
RecExists = (DCount("*", "Itinerary", Jetwhere) = 0)
If RecExists = False Then
SpecName = Me![Specialist].Column(1)
Msg = SpecName & " has an existing Activity on that date, please choose
another date or Person"
MsgBox Msg, vbCritical, "Duplicate Data"
Cancel = True
Me.ReviewDate.Undo
End If
record does not already exist. It produces an access system error though (see
below). I want it to remove the ReviewDate but leave the rest of the data
hence me.reviewdate.undo - but this does not work.
If I put it in the afterupdate event of the control I don't get the
violation error but the undo still does not work.
I am doing it this way as I want the validation checking for the data to
take place before a save record is performed. That way if the navigation
buttons are pressed I won't get any errors from an unsuccessful save.
Can anyone help with this as I am going round in circles and its doing my
head in...
Thanks
Acess system error produced:
"The value in the field violates a validation rule for the record or
field." "For example you may have changed a validation rule without
verifying whether the existing data matches the new validation rule."
My validation code:
(called from Private Sub ReviewDate_BeforeUpdate(Cancel As Integer))
Jetwhere = "[ReviewDate] = #" & Format$(CheckDate, "mm\/dd\/yyyy") & "#" &
"AND Specialist = " & _
Format(SpecID, "0") & "AND ItineraryID <> " & ItinID
RecExists = (DCount("*", "Itinerary", Jetwhere) = 0)
If RecExists = False Then
SpecName = Me![Specialist].Column(1)
Msg = SpecName & " has an existing Activity on that date, please choose
another date or Person"
MsgBox Msg, vbCritical, "Duplicate Data"
Cancel = True
Me.ReviewDate.Undo
End If