This is the table of patient and the appointment.
Table Patient
Rn
Name
Id
Dob
Address
Phone No
Status of Death
Table Appointment
Id
Date of registration
Time of registration
Time of seeing doctor
Waiting time
The Waiting Time field should *simply not exist* in your table. Instead, just
store the time of registration and the time of seeing doctor, and calculate
the waiting time dynamically with a query calculated field:
WaitingTime: DateDiff("n", NZ([Time of Registration], Time()), NZ([Time of
Seeing Doctor], Now()))
This will calculate how long the patient waited if there is information
available in both fields, and how long they've been waiting up until the
present moment if there is nothing in [time of seeing doctor]. Just use the
fieldnames rather than the NZ() function call if there will alsways be data.
You can nest this function inside an IIF to count the patients with various
waiting times. This query should work:
SELECT Count(*) AS NumberofPatients, Sum(IIF(DateDiff("n", [Time of
Registration], [Time of Seeing Doctor]) < 90, 1, 0) AS Under90Minutes
FROM [Table Appointment]
WHERE [Date of Registration] >= DateSerial(Year([Enter a date in desired
month:]), Month([Enter a date in desired month:]),1) AND [Date of
Registration] < DateSerial(Year([Enter a date in desired month:]),
Month([Enter a date in desired month:]) + 1,1);
--
John W. Vinson [MVP]
Does [Table Appointment] have a primary key? If not, it needs one.
I would recommend that you NOT use blanks in fieldnames - it's legal but can
cause hassles later on.- Hide quoted text -
- Show quoted text -