473,656 Members | 2,776 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 1428
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
7867
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 something like this: For a (very) simple table containing three rows like this: row 1: A
2
6545
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 tblClearance. I was thinking of placing the code on the form's BeforeUpdate event so that it will fire whether the user closes the form or attempts to create another record.
3
1770
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 possibly be doing wrong on this? Thanks for the help, Stephen
6
29932
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 newsgroups, the access support centre, I can seem to find no similar situation. I am not using any references, or VBA at all in the first place. I am trying to set up a simple (or so I thought) query to work with the text of two tables. ...
3
12711
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 am displaying consists of a work order schedule(for the current date), work orders completed , work orders not completed, a past due schedule, past due completed, and past due not completed. These are grouped by workcenters. Therefore, one...
22
2695
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 things. So, in instances where I list, for example, the latest weblogs. I list the headline of the weblog, the date and the name of the member who wrote it. Now, the name isn't just "Smith", but rather Smith's online status, his nick and his...
2
2317
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 , these queries select some rows from the linked tables and insert them in MS access local tables . I am facing problem while executing these queries . The problem is that -- through the code ; when i am asking these query to execute , it prompts...
16
3487
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 renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
2
9834
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 to open in datasheet view. As an experiment, I deleted all rows in all tables; after that, the query took only seconds to open in both design view and datasheet view. From these facts, I conclude that Access is evaluating the query when I go to...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.