Results 1 to 4 of 4
  1. #1
    Kivan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    27

    Post Append query question

    Hi,



    I have 3 tables, Person (which holds name of person etc.), Project (which holds name of project etc.) and ProjectMetrics (which holds particular project name and person name and some other data connected with particular person and project). Now I have an append query which appends project name (from project table) and person name (from person table) to the table ProjectMetrics. This query is created to help user assigning people to the projects (so there is a parameter ProjectName so if user want to append people to the project he write the name of that project and Voilą). The problem is user can append particular people to the project with no limit. So for example if user will run this query 3 times there will be:

    Code:
    Name                 Project
    John Doe              Fire
    John Doe              Fire
    John Doe              Fire
    And I want that John Doe to appear only one time in the project even after running query 3 times. Is there any possibility of doing this? Ah and I would't like to make Name and Project as primary keys in the ProjectMetrics table.

    Here the SQL code.

    Code:
    PARAMETERS ProjectName Text ( 255 );
    INSERT INTO [ProjectMetrics] ( Person, Project )
    SELECT Person.IdPER, Project.IdPRO
    FROM Person, Project
    WHERE (((Project.[ProjectName])=[ProjectName]));

  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,742
    I would suggest that the fields in your Projectmetrics table be changed to PersonId and ProjectId. Both of these should be long integer type. (The fields as you have them would have same names as your tables -- confusing at best),
    In table ProjectMetrics make a unique index on the combination PersonId + ProjectId

    Perhaps you already have this
    -In your Person table, I would have a PersonId field that is autonumber and PK.
    -In the Project table, I would have a ProjectId field that is autonumber and PK.

    When you do this and run the query multiple times, Access will give you an error message saying that if you were to store that data you would create a duplicate record. So you will need to look for error conditions.

  3. #3
    Kivan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    27
    Works perfectly, I didnt even know that there is possibility like that. Thanks a LOT .

  4. #4
    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,742

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

Similar Threads

  1. Append Query Question
    By kwooten in forum Queries
    Replies: 4
    Last Post: 01-17-2012, 11:51 AM
  2. Append Query question
    By MiserableLawStdnt in forum Queries
    Replies: 2
    Last Post: 11-21-2011, 03:12 PM
  3. Append Query Question
    By chewbears in forum Access
    Replies: 9
    Last Post: 11-18-2011, 03:06 PM
  4. Replies: 1
    Last Post: 10-06-2011, 08:37 AM
  5. Append Query Question
    By JackA in forum Queries
    Replies: 5
    Last Post: 08-02-2011, 03:59 AM

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