H
hughess7
Hi all
I have some code in the beforeupdate of a form which checks that the date
and person entered is unique and does not already exist. This works for a new
record but if you are changing an existing record it finds itself and
therefore fails to save changes (please see code below).
Is there a way to differentiate between a new and an amended record - I
think it would maybe work if I added a field as a flag and entered a value in
that field once record had been saved, then check this field when save takes
place? Or is there a better way to do this?
If UniqueRec([ReviewDate], [Specialist]) = False Then
Cancel = true
etc
Function UniqueRec(CheckDate As Date, SpecID As Integer) As Boolean
Dim Jetwhere As String
Jetwhere = "[ReviewDate] = #" & Format$(CheckDate, "mm\/dd\/yyyy") & "#" &
"AND Specialist = " & Format(SpecID, "0")
UniqueRec = (DCount("*", "Itinerary", Jetwhere) = 0)
Thanks in advance for any help.
Sue
I have some code in the beforeupdate of a form which checks that the date
and person entered is unique and does not already exist. This works for a new
record but if you are changing an existing record it finds itself and
therefore fails to save changes (please see code below).
Is there a way to differentiate between a new and an amended record - I
think it would maybe work if I added a field as a flag and entered a value in
that field once record had been saved, then check this field when save takes
place? Or is there a better way to do this?
If UniqueRec([ReviewDate], [Specialist]) = False Then
Cancel = true
etc
Function UniqueRec(CheckDate As Date, SpecID As Integer) As Boolean
Dim Jetwhere As String
Jetwhere = "[ReviewDate] = #" & Format$(CheckDate, "mm\/dd\/yyyy") & "#" &
"AND Specialist = " & Format(SpecID, "0")
UniqueRec = (DCount("*", "Itinerary", Jetwhere) = 0)
Thanks in advance for any help.
Sue