hi
I have a little bit of code that uses a DLookup to prevent users from entering duplicate values, as below:
Private Sub groupIDFK_BeforeUpdate(Cancel As Integer)
justchosen = Me.groupIDFK
previouschosen = DLookup("groupIDFK", "jun_groupevent", "patientIDFK=[forms]![frm_patientdetails].[patientID] And groupIDFK=[forms]![frm_patientdetails].[sf_jun_groupevent].[form]![groupIDFK]")
If justchosen = previouschosen Then
MsgBox ("This patient is already recorded as a member of this group")
Cancel = True
Me.Undo
Me.Requery
Else
End If
End Sub
The code works insofar as it is able to tell if the duplication has occurred, and the duplicate value as undone as a result. However, after it does this it comes up with the error "No current record". Any ideas what I am doing wrong? As always, any help greatly appreciated.
cheers,
Bruce
I have a little bit of code that uses a DLookup to prevent users from entering duplicate values, as below:
Private Sub groupIDFK_BeforeUpdate(Cancel As Integer)
justchosen = Me.groupIDFK
previouschosen = DLookup("groupIDFK", "jun_groupevent", "patientIDFK=[forms]![frm_patientdetails].[patientID] And groupIDFK=[forms]![frm_patientdetails].[sf_jun_groupevent].[form]![groupIDFK]")
If justchosen = previouschosen Then
MsgBox ("This patient is already recorded as a member of this group")
Cancel = True
Me.Undo
Me.Requery
Else
End If
End Sub
The code works insofar as it is able to tell if the duplication has occurred, and the duplicate value as undone as a result. However, after it does this it comes up with the error "No current record". Any ideas what I am doing wrong? As always, any help greatly appreciated.
cheers,
Bruce