Results 1 to 4 of 4
  1. #1
    stacynh is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Michigan
    Posts
    8

    Smile Automatically update a Table based on values in another Table

    Hello Everyone,




    I am hoping for some help automating a task in Access. I have scoured forums and YouTube, but so far, no luck...


    In the same database, I have a "Item Distribution" table and a "Item Serial Number" table.


    The Item Distribution table includes (among other things):
    -A Serial Number field: Pulls values from the other table;
    -A Item Returned Date field;
    -A Date Updated field


    The Item Serial Number table includes (among other things):
    -A Serial Number field;
    -A Current Location field;
    -A Date Updated field.


    When a new record is added to the Item Distribution Table, I would like the Item Serial Number Current Location field to change to "Assigned." When a returned date is added to an existing record on the Item Distribution table, I would like the Item Serial Number Current Location to change to "Stock." In both cases, the Item Serial Number Date Updated field should also update.


    Is there any way to automate this?


    LIMITATIONS:
    1. The same Item Serial Number may be listed multiple times on the Item Distribution table, should the same item have been signed out and returned multiple times. I am interested in the most recent change to a record with that serial number.


    2. There are additional location possibilities on the Item Serial Number table that would never appear on the Item Distribution table, (such as "Repair Shop" or "Destroyed").


    Thank you very much for your time!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    To get the most recent one make a select query on the table : select [serialNum],MAX(UpdDate)
    now make an update query , this will set the new date based on the select query above, but you cannot join the 2 queries. (you cant sum/Max and update in the same query)
    You must update using the IN clause.

    as an example, use the query wizard to create a FIND DUPLACATES query. Then look at the resulting sql. Do this to update your table.
    If you cannot, write the Select query to a table, THEN update your data from this 'temp' table.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It sure looks like there is a Normalization issue as the actual "Serial Number" should only be in one table and every other table just has the PK field of that record. Of course, I could be wrong here.

  4. #4
    stacynh is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Michigan
    Posts
    8
    Thank you! I think this may be a little beyond my current abilities, but I will work on it! Thanks for the help!


    Quote Originally Posted by ranman256 View Post
    To get the most recent one make a select query on the table : select [serialNum],MAX(UpdDate)
    now make an update query , this will set the new date based on the select query above, but you cannot join the 2 queries. (you cant sum/Max and update in the same query)
    You must update using the IN clause.

    as an example, use the query wizard to create a FIND DUPLACATES query. Then look at the resulting sql. Do this to update your table.
    If you cannot, write the Select query to a table, THEN update your data from this 'temp' table.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-07-2015, 02:11 AM
  2. Replies: 2
    Last Post: 04-15-2015, 10:05 AM
  3. Replies: 6
    Last Post: 11-22-2013, 07:59 PM
  4. Replies: 1
    Last Post: 10-29-2012, 08:15 AM
  5. Replies: 4
    Last Post: 04-18-2011, 07:18 AM

Tags for this Thread

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