Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    London
    Posts
    341

    Exclamation Unanswered: Please help - Code Problem - Disgarding duplicates

    Hi Guys,

    I'm trying to stop users creating duplicate Training Events on my system but I'm having a real big problem doing this. I've been experimenting with codes and so far I have the below set up but the program breaks on Set rsc As DAO.Recordset

    Can someone help me fix this code?



    Public Sub Val_Trainer_AfterUpdate()

    Dim EventLinkCriteria As String
    Dim rsc As DAO.Recordset

    Set rsc = Me.RecordsetClone

    EventLinkCriteria = Me.Val_Date & Me.Val_TrainingCourse & Me.Val_TrainingVenue & Me.Value_Trainer

    'Check StudentDetails table for duplicate StudentNumber
    If DCount("Date" & "Training Course" & "Training Venue" & "Trainer", "Tbl_Courses", EventLinkCriteria) > 0 Then
    'Undo duplicate entry
    Me.Undo
    'Message box warning of duplication
    MsgBox "Warning Course Event 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 EventLinkCriteria
    Me.Bookmark = rsc.Bookmark
    End If

    Set rsc = Nothing

    End Sub

  2. #2
    Join Date
    Jun 2004
    Posts
    92
    Quote Originally Posted by christyxo
    I've been experimenting with codes and so far I have the below set up but the program breaks on Set rsc As DAO.Recordset
    What do you mean it's breaking? What error is it giving you. Also, have you made sure to add references to the DAO DLL?

  3. #3
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    Compile Error:

    User-defined type not defined.

    References to the DAO DLL? I'm actually new to VB so I guess I've missed that. How would I reference this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •