Results 1 to 8 of 8
  1. #1
    Brownie1987 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Location
    UK
    Posts
    7

    Querying cascading tables

    Hi,

    I'm struggling with getting a query to function looking across multiple tables to create a report.

    The context is that I am trying to build a database for patient records, so that we can both produce a daily, usable list and audit various aspects.

    The tables in use are: Patients, Admissions, Operations and Complications. They are related as follows:

    Every admission relates to a single patient. Each operation relates to a single admission for a single patient. Each Complication relates to a single operation, on a single admission for a single patient.

    Each is linked by a primary key (Medical Record Number in Patients, AdmissionID in Admissions etc) which is one-to-many related to a FK field in the subsequent tables. (Complications has FK fields for MRN, Admission and Operation etc).



    (Ideally, I eventually also want a problems table which was valid for each admission per patient; but for the time being am using a short text field in Admissions)

    I've built a query which ran successfully just around patients and admissions. However, as I wanted to build a report which showed a list of currently admitted patients and included their operations and complications, I needed to build a query which pulled all of this info.

    When I run the query, however, it returns no records.

    Can anyone suggest a solution, please?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Hard to say without seeing the query, but I'd guess you need to edit the join(s) between tables. Right or double click on the join line to do that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Brownie1987 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Location
    UK
    Posts
    7
    Thank you.

    To be clear, what do I need to do to make that work? Currently, they are set up as one-to-many with enforced referential integrity and cascaded updates.

    I had assumed the problem has to do with the fact that there might be multiple operations per admission per patient and the simple tabular return which the query gives might not have been able to handle that?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    So you didn't try it? A query can handle multiple records; what it won't by default is if there are no records in the many table. Changing the join will fix that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Brownie1987 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Location
    UK
    Posts
    7
    I'm very novice so I'm not sure what I need to do! I think that's the exact problem, having had a bit more of a play with things.

    Can you tell me precisely what I need to do to fix that, please?

    Thanks

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Sorry, I thought I did. With the query in design view:

    Quote Originally Posted by pbaldy View Post
    Right or double click on the join line to do that.
    The correct choice should be obvious at that point.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Brownie1987 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Location
    UK
    Posts
    7
    I was trying to mess around with the relationships. Couldn’t work out what you meant!

    Thanks, that’s fixed it.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Querying linked tables
    By atbm in forum Queries
    Replies: 5
    Last Post: 08-04-2017, 02:35 PM
  2. Querying Three Joined Tables with Nulls
    By DHaedo in forum Queries
    Replies: 4
    Last Post: 06-21-2016, 11:09 AM
  3. Replies: 13
    Last Post: 06-18-2014, 06:20 PM
  4. Querying 2 or more tables
    By NewbieInCT in forum Queries
    Replies: 12
    Last Post: 05-11-2012, 09:49 AM
  5. Querying from 2 tables
    By egnaro in forum Queries
    Replies: 6
    Last Post: 01-28-2010, 06:30 PM

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