Object invalid or no longer set (go to original record)

ikzouhetnietweten

Registered User.
Local time
Today, 15:02
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


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
 

Attachments

I'm not understanding your question? I have entered several records into "KLANTNAAM:" with no problems.
 
Try filling in a value that already exists like I stated in my initial post. try to fill in the word 'Lol' and then go to the next field. You will get an error.
 
Oh! I thought you were trying to be funny! LOL....
 
Try This:-

Code:
Private Sub Klantnaam_BeforeUpdate(Cancel As Integer)

   Dim stLinkCriteria As String

    stLinkCriteria = "[Klantnaam] = '" & Me.[Klantnaam].Value & "'"
    'Check Assets table for duplicate [Klantnaam]
    If DCount("Klantnaam", "Klanten2", stLinkCriteria) > 0 Then
        'Undo duplicate entry
        Me.Undo
        'Message box warning of duplication
        MsgBox "Warning Klanten2 " _
             & Me.[Klantnaam].Value & " has already been entered." _
             & vbCr & vbCr & "You will now be taken to the record.", _
               vbInformation, "Duplicate Information"
        'Go to record of original Student Number
                Me.DataEntry = False
        Me.Recordset.FindFirst stLinkCriteria
    End If

End Sub
 
Thats the one, thanks! Your right, I got it from there but the gotoRecord code didnt work, but yours did +rep
 

Users who are viewing this thread

Back
Top Bottom