Help Detecting a Duplicate entry on a Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PabSal
    New Member
    • Feb 2012
    • 1

    Help Detecting a Duplicate entry on a Form

    I have a Table for certain product, there is Two product type (Regular and Reinforced) Each has their independent serial number and I want to be able to display an error if the serial number has already been added.
    I have no experience with MS Access but I been reading a lot but I cannot figure this out.

    Thanks

    PS
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    First off, the thing to do is to ensure this can never happen by designing the table such that the unique field has a unique index. Such a design will ensure that Access never allows such data to be entered in the first place.

    Of course, if the dodgy data is already there and in place, you need to find it. A query can help with that. If you link set criteria in the query to ensure only [ID]s where the Count() of those [ID]s is greater than one are included. The example SQL below illustrates the idea :
    Code:
    SELECT [ID]
         , [Name]
    FROM   [YourTable]
    WHERE  [ID] In(SELECT   [ID]
                   FROM     [YourTable]
                   GROUP BY [ID]
                   HAVING   Count(*) > 1)

    Comment

    Working...