query for duplicates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • juster21
    New Member
    • Feb 2008
    • 24

    query for duplicates

    I have a data-entry application which saves records to an Access db. I need to build in a query to search for duplicate entries before a save is performed. There are 2 fields that would generate a duplicate; UserID and WeekEndingDate. If more than 1 record is found for the same combination I want to have a pop-up message saying that the combo already exists. Thanks for the help!!

    p.s. - I am coding in vb.net
  • rkeith27
    New Member
    • Mar 2008
    • 6

    #2
    If I understand it correctly...
    I didn't try the query but it should be correct, if not it's real close.


    SELECT userID,
    COUNT(userID) AS userID_NumOccur rences, weekEndingDate,
    COUNT(weekEndin gDate) AS weekEndingDate_ NumOccurrences
    FROM tableA
    GROUP BY userID, weekEndingDate
    HAVING ( COUNT(userID) > 1 AND COUNT(weekEndin gDate) > 1)

    Comment

    • juster21
      New Member
      • Feb 2008
      • 24

      #3
      Originally posted by rkeith27
      If I understand it correctly...
      I didn't try the query but it should be correct, if not it's real close.


      SELECT userID,
      COUNT(userID) AS userID_NumOccur rences, weekEndingDate,
      COUNT(weekEndin gDate) AS weekEndingDate_ NumOccurrences
      FROM tableA
      GROUP BY userID, weekEndingDate
      HAVING ( COUNT(userID) > 1 AND COUNT(weekEndin gDate) > 1)
      thanks for the help. Any chance you could help translate this into a SQL statement for use in vb code? The ultimate goal is to produce an error message if the count is greater than 1. Thanks again!!

      Comment

      Working...