473,503 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Relating information in a query to other tables & queries

1 New Member
Hi there. I am quite new to MS-Access and databases in general, so please bear with me if this is a very basic question.

I am trying to create a database in Access 2000 that will track patients as they move from room to room in a hospital setting. I have a table for patient demographics, called “Patients”, one for room numbers and information, called “Rooms”, and one for information on movements from room to room, called “Movement.” “Patients” consists of a medical record number field as the primary key, and a number of text fields containing demographic information. “Rooms” consists of a text field with room numbers as the primary key and a text field for room type. “Movement” consists of a field for medical record number, a date and time field, a starting room field and an ending room field. The medical record number field in “Movement” is related to that in “Patients”, and the starting and ending room fields are both related to the room number field in “Rooms.”

I need to create a query or a report that will show only the most recent movement record for each patient, and then filter out those records whose ending room is not of a certain type, essentially a census of a given unit.

What I have tried is creating a query as such:

Select EndRoom, Max(DateTime) as LastTime
From Movement
Group by EndRoom

Things work reasonably well up until this point. This query spits out a list of rooms and with the last time a patient was moved into them.

However, when I go the design view and attempt to add other fields, strange things happen. If I add fields from “Patients” I start to get multiple records per room. If I add the “RoomType” field from “Rooms” and try to add a criteria so that I only get the room types I want, I get records that appear to be largely random.

Can anybody suggest anything? I would be extremely grateful for any help.

Jason Merrill
Aug 4 '07 #1
1 1420
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hi there. I am quite new to MS-Access and databases in general, so please bear with me if this is a very basic question.

I am trying to create a database in Access 2000 that will track patients as they move from room to room in a hospital setting. I have a table for patient demographics, called “Patients”, one for room numbers and information, called “Rooms”, and one for information on movements from room to room, called “Movement.” “Patients” consists of a medical record number field as the primary key, and a number of text fields containing demographic information. “Rooms” consists of a text field with room numbers as the primary key and a text field for room type. “Movement” consists of a field for medical record number, a date and time field, a starting room field and an ending room field. The medical record number field in “Movement” is related to that in “Patients”, and the starting and ending room fields are both related to the room number field in “Rooms.”

I need to create a query or a report that will show only the most recent movement record for each patient, and then filter out those records whose ending room is not of a certain type, essentially a census of a given unit.

What I have tried is creating a query as such:

Select EndRoom, Max(DateTime) as LastTime
From Movement
Group by EndRoom

Things work reasonably well up until this point. This query spits out a list of rooms and with the last time a patient was moved into them.

However, when I go the design view and attempt to add other fields, strange things happen. If I add fields from “Patients” I start to get multiple records per room. If I add the “RoomType” field from “Rooms” and try to add a criteria so that I only get the room types I want, I get records that appear to be largely random.

Can anybody suggest anything? I would be extremely grateful for any help.

Jason Merrill
Place your query in design view. Right click anywhere in the table area of the query grid (the open area only; do not click on a table). This will bring up a shortcut menu from wihich you will select "Properties". In the query property sheet, set "unique values" to yes.....run your query....it should be working the way you want it to. Setting the unique value property to yes is the same as using the "Distinct" keyword.
Aug 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7849
by: Jonathan | last post by:
Hi all! For a match schedule I would like to find all possible combinations of teams playing home and away (without teams playing to themselves of course). I now the simple version works...
2
6525
by: Paul Wagstaff | last post by:
Hi there I have 2 tables: tblAccuracy & tblClearance Users add new records to tblAccuracy using frmRegister. Under specific conditions I need to append the current record from frmRegister into...
3
1766
by: Stephen | last post by:
It is possible to relate queries to tables, right? It seems logical but when I try to match my queries to any of the tables or even to each other it gives me a blank relationship. What could I...
6
29925
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
3
12691
by: matthewemiclea | last post by:
I am trying to display information in Access on a form that takes information from many different queries and puts them together on a spreadsheet or chart. Some specific info: The information I...
22
2661
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
2
2303
by: Chandan Ahuja | last post by:
Hello , I use MFC DAO classes to access my MS access database . I am using some linked tables(Linked to Oracle) in my MS Access database . Also i have some queries in my databse ,...
16
3462
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
2
9816
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.