Results 1 to 2 of 2
  1. #1
    lugnutmonkey is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    42

    Smile Three variables for Criteria

    I am wondering if it is possible to use three criterias (Representative ID, Month and Year) to make sure that I dont append duplicates into a table.

    Essentailly I have a record where the combination of REP ID, Month and Year together should always be a unique combination. So by applying a criteria similar to this:
    Code:
    Query1.REP ID, Query1.Month], Query1.Year <> Table1.REP ID, Table1.Month, Table1.Year
    Can anybody help me out with the code?

    Or would I be better off using those three fields as a comibnation key in the table?

  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,848
    In your table make a unique composite index of the 3 fields involved.
    Access will give an error message probably 3022 if you try to add a duplicate.

    None of the fields in the index can be null, you must have values for
    REP ID, Month and Year

    NOTE: You should not use a naming convention that allows spaces or special characters in field names.
    Year and Month are RESERVED WORDS in Access.

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

Similar Threads

  1. Find top 3 variables
    By NISMOJim in forum Programming
    Replies: 5
    Last Post: 12-14-2012, 03:11 AM
  2. Using VBA Variables in a SQL statement
    By saltydawg617 in forum Access
    Replies: 3
    Last Post: 07-28-2011, 02:59 PM
  3. VBA variables in SQL
    By compooper in forum Programming
    Replies: 3
    Last Post: 07-06-2011, 11:04 AM
  4. VBA in variables
    By smikkelsen in forum Access
    Replies: 3
    Last Post: 11-12-2010, 03:14 PM
  5. sql in vb variables
    By emilylu3 in forum Programming
    Replies: 3
    Last Post: 03-04-2006, 01:26 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