Results 1 to 4 of 4
  1. #1
    dkeeper09 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    15

    multiple query help

    Hey guys.



    I am going to try and explain my problem the best I can. Any help is greatly appreciated.

    I have some tables, employees, assets, terminated assets, and terminated employees. I have created queries for these tables as well.

    I have a checkbox column in my employee table. So when it is unchecked, the employee is removed and added to the terminated employee table.

    My problem is the employee is still being tied to the assets. Each employee can have multiple assets. When i move the employee to the terminated table, i want the employee's name to be removed from the asset table and moved to terminated assets. I don't want to whole entry deleted, because another employee will use that asset. Is there a way to get it to just remove the employee's name from the asset it is tied to?

    I hope this makes sense. Like i said, i appreciate any help that can be given. Thank you!

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    First of all, you should not have the terminated assets or terminated employees tables. One of the primary rules is that similar data should be in 1 place. Having two employee tables or two asset tables violates that rule. It would be better to have a field in the asset table and a field in the employee table that designates that the asset/employee is no longer active. You can use a simple yes/no field. I typically use a date field since it yields a little more information about when the asset or employee was inactivated/terminated. You can use that field to filter your queries. It also sounds like you are missing a table since you say that an asset can go to another person when the employee who used the asset is terminated. Since an asset can be used by many people (over time), it describes a one-to-many relationship. Since you also said that a person can have many assets, that describes another one-to-many relationship. When you have 2 one-to-many relationships between the same two entities (employees & assets in your case), you have a many-to-many relationship which requires a junction table.

    tblEmployees
    -pkEmpID primary key, autonumber
    -txtFName
    -txtLName
    -dteTerminated (termination date)

    tblAssets
    -pkAssetID primary key, autonumber
    -txtAssetName
    -dteTerminated


    tblEmployeeAssets (the junction table)
    -pkEmpAssetID primary key, autonumber
    -fkEmpID foreign key to tblEmployees
    -fkAssetID foreign key to tblAssets
    -dteEffective (effective date--when the asset was assigned to the person)

  3. #3
    dkeeper09 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    15
    i will definitely try this out. thanks a bunch!

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. Please post back with any questions

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

Similar Threads

  1. SUM Multiple fields in a query
    By Thoudus in forum Queries
    Replies: 3
    Last Post: 02-24-2011, 09:11 AM
  2. Query Multiple Tables
    By Tomfernandez1 in forum Queries
    Replies: 1
    Last Post: 02-04-2011, 09:31 PM
  3. Multiple count query
    By aajay05 in forum Queries
    Replies: 2
    Last Post: 03-08-2010, 10:00 AM
  4. Multiple Table query
    By bibbyd01 in forum Queries
    Replies: 1
    Last Post: 10-06-2009, 09:12 AM
  5. VBA SQL Query of Multiple Databases
    By VBA_Rookie in forum Programming
    Replies: 0
    Last Post: 12-02-2008, 12:32 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