Results 1 to 4 of 4
  1. #1
    marculos is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2015
    Posts
    2

    Updating a field based on a count from another table

    Hi, I have been struggling with the problem all day ..

    I have
    table a


    field - patient a
    field - patient ref
    field - number of heath issues

    table b
    field - patient ref
    field - heath issue X

    So I want to get the count of health issues for patient a from table b to produce something like below.

    patient a, refa12345, 5
    patient b, refb12345, 2
    patient c, refc12345, 8


    what is the best approach to take with ms access to do this ? I have tried an UPDATE query but doesnt seem to want to work as can't use joins.
    Appreciate any help here.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Easiest way, make 2 queries
    Q1 make table that counts the health issues for each patient. write to a table T1.
    Q2 is an update query that uses the table made from Q1 and TableA together....
    UPDATE tableA INNER JOIN T1 ON tableA.ClientID = T1.ClientID SET tableA.CountOfIssues= [T1].[CountOfIssues];

    (you have to make table because you cant sum and update in the same query)

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Usually a bad idea to save aggregate data. Calculate when needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    marculos is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2015
    Posts
    2

    Thanks !

    Thanks for all the help peeps !!

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

Similar Threads

  1. Updating Multiple Record Form Based on Record Count
    By William McKinley in forum Forms
    Replies: 2
    Last Post: 12-31-2014, 12:45 PM
  2. Replies: 0
    Last Post: 07-03-2014, 12:15 PM
  3. Replies: 3
    Last Post: 07-18-2013, 04:21 AM
  4. Replies: 6
    Last Post: 05-10-2012, 08:20 PM
  5. Replies: 2
    Last Post: 07-07-2011, 08:25 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