Results 1 to 2 of 2
  1. #1
    littlejnz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    1

    Prevent user adding duplicate data in form

    Hi. I have two linked forms. RaceName and Entries. Entries comprises entries for all races. RaceName is details relating to a specific race only. I intended to use the following code to restrict a boat or person being entered twice in the same race in the Entries table.

    Private Sub Entries_skipperhandicap_AfterUpdate()
    Dim NewHandicapID As String
    Dim StLinkCriteria As String
    NewHandicapID = Me.HandicapID.Value


    StLinkCriteria = "[HandicapID]=" & "'" & NewHandicapID & "'"
    If Me.HandicapID = DLookup("[HandicapID]", "tbl_Entries", StLinkCriteria) Then
    MsgBox "This Skipper, " & HandicapID & ", Has Already Entered - Can't Enter Twice!" _
    & vbCr & vbCr & "Please Check Skipper Name again.", vbInformation, "Duplicate Information"
    Me.Undo
    End If
    End Sub

    However, Access is returning runtime error 3078 - can't find table. I suspect this might be problem relating to the form/subform, cant cant figure it. Any ideas?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Tables contain/store data.
    Forms are a way of displaying data in a table.

    You prevent duplication in a table by making a unique field the Primary Key.
    You can also make a composite unique index on multiple fields to prevent duplicates of this field combination.

    You check an input form for duplicates using a DCOUNT() function and ensure it is 0 in the BeforeUpdate event of a control.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-10-2014, 08:51 AM
  2. Duplicate data entry on form level by user
    By Kananelo in forum Forms
    Replies: 1
    Last Post: 02-10-2012, 01:09 AM
  3. Replies: 3
    Last Post: 01-05-2012, 09:57 AM
  4. Replies: 2
    Last Post: 12-07-2011, 02:51 AM
  5. Replies: 2
    Last Post: 02-12-2011, 09:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums