ikzouhetnietweten
Registered User.
- Local time
- Today, 20:45
- Joined
- Oct 23, 2015
- Messages
- 44
Im having a form, and it gives me a warning if its a duplicate, that works. SO try to fill in at KLANTNAAM: Lol and then go to the next field, im getting the duplicate box but its not getting me to that record thats a duplicate. (original one)
Im getting an error: Object invalid or no longer set.
Any idea how the form should get me to the original record.
THe problem is here: rsc.FindFirst stLinkCriteria
Im getting an error: Object invalid or no longer set.
Any idea how the form should get me to the original record.
THe problem is here: rsc.FindFirst stLinkCriteria
Code:
Private Sub Klantnaam_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.Klantnaam.Value
stLinkCriteria = "[Klantnaam]=" & "'" & SID & "'"
'Check StudentDetails table for duplicate StudentNumber
If DCount("Klantnaam", "Klanten2", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If