Results 1 to 9 of 9
  1. #1
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39

    How to check if there is duplicate entry

    hello again. I am trying to check if there's a way that when I entered a value in my form, it will tell me that it is already existing. For example, I entered 1001 in the text field name order number with control source of "orderNum", and this text box will be appended automatically by " / 2013", this will then look up all the values in the "orderNum" column of the table. If there is an existing number, it will display a messages box like "This Order Number is existing". I am trying to search for it over here and other sites but I can't seem to find an answer. Thanks for the usual help. Regards Undee

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use a .FindFirst on the RecordSetClone in the BeforeUpdate event of the control.
    If Not Me.RecordsetClone.NoMatch Then
    ...it already exist!

  3. #3
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    not sure how to do that ^_^

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm not sure where to start helping then. What is the name of your Control and the name of the Field to which it is bound?

  5. #5
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    Here you go.

    Form Name: frmTransaction
    Control Name: Delivery Note Number
    Bound to Field: dlvryNoteNum
    Table name: tblDeliveryTransaction

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Keeping in mind this is just a guess...it will look something like:
    Code:
    Private Sub Delivery_Note_Number_BeforeUpdate(Cancel As Integer)
       Me.RecordsetClone.FindFirst "[dlvryNoteNum] = " & Me.[Delivery Note Number]
       If Me.RecordsetClone.NoMatch Then
          '-- Not a duplicate
       Else
          MsgBox "This is a duplicate Number!"
          Cancel = True
       End If
    End Sub
    You will need to tweak this to your own specifications.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    BTW, embedded spaces in names will *always* be problematic. Better to use something like CamelFontNames.

  8. #8
    undee69 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    39
    Thanks for the assistance and tip ^_^

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Post back to this thread if you still can't get it working.

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

Similar Threads

  1. Replies: 3
    Last Post: 11-02-2012, 11:00 AM
  2. check duplicate records within same table
    By cthorn112 in forum Queries
    Replies: 0
    Last Post: 06-19-2012, 12:23 PM
  3. check text box after update for duplicate
    By smahdih in forum Access
    Replies: 1
    Last Post: 11-05-2011, 05:35 PM
  4. check for duplicate First and Last names?
    By newtoAccess in forum Access
    Replies: 3
    Last Post: 03-19-2011, 04:05 PM
  5. Replies: 0
    Last Post: 03-09-2011, 02:59 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