If you are trying to find patients who were discharged after a date you
specify for [DATE SENT TO PEB], open the query in design view. In the
Criteria row for that field, put:
If another field has a criteria, add that. For instance, let's say the
criteria for [DateOfBoard] is:
<DateAdd("d",-15,Date)
If you also want to see records for which [DATE SENT TO PEB] is null, in
the
Or row in query design view, directly below the Criteria row, put:
Is Null
If you want the same criteria for DateOfBoard, add it again to the Or row
for that field, directly below where you entered the DateAdd expression
in
the criteria row.
The logic here is:
Find all records in which [DATE SENT TO PEB] is after a specified date
and
[DateOfBoard] is earlier than fifteen days ago, or in which [DATE SENT TO
PEB] is null and [DateOfBoard] is earlier than fifteen days ago.
You can shorten this process by entering in the criteria row for [DATE
SENT
TO PEB]:
[Enter a date] Or Is Null
In [DateOfBoard], use the DateAdd expression as stated above.
I used [DateOfBoard] just to illustrate having another field with a
criteria. There is no requirement to add any other criteria, or you can
add
criteria for several fields.
BTW, when asking a question you would do well to remember that we cannot
see
your database, nor do we know your jargon. If you are asking about the
discharge date field, it would help to call it [DischargeDate] rather
than
leaving it for others to sort out that [DATE SENT TO PEB] is the
discharge
date. Sorting that out took time away from trying to address the actual
question.
On another point, there does not seem to be a need for [SENT TO PEB]. If
there is no date, the patient was not discharged.
DandimLee said:
If I put "is Null" in the criteria, can I also put in a < or > criteria
for
the date? This is so that the resulting count includes the patients
who
were
discharged (Master.[Sent to PEB]) after the date I specify in [DATE
SENT
TO
PEB]. I'm trying to count the number of active patients within a
certain
time frame (3 weeks ago, 2 weeks ago, etc.). Some of those patients
are
going to be active through the entire month, while some patients will
be
admitted in the middle of month, or be discharged within the month,
which
is
why I need to have the [DATE SENT TO PEB] be null or be greater than
the
selected date.
:
If you want to include records with no entry in [DATE SENT TO PEB], in
query
design view, in the OR row, add "Is Null" (without the quotes). For
the
rest of the fields (Master.PEB, etc.), duplicate in the Or row the
information from the Criteria row as needed.
A difficulty I am having understanding what is going on here is that
you
want to filter according to whether the patient has been discharged,
but
I
don't know which field shows that information.
For the rest, you may be over-complicating it. From what I can tell,
you
need to show all patients who have not been discharged. If that
information
is a Yes/No field, you simply do not provide any criteria for that
field.
SELECT Master.[Date of Board], Master.PEB, DateDiff("d",[Date of
Board],Now()-21) AS Days
FROM Master
GROUP BY Master.[Date of Board], Master.PEB, Master.[SENT TO PEB],
Master.TERMINATED, Master.[No Longer Tracking], Master.BMIA,
Master.Transfer,
Master.Other, Master.TBTR, Master.ADDENDUM, Master.SUS, Master.[DATE
SENT
TO
PEB]
HAVING (((Master.[Date of Board])<Now()-21) AND ((Master.PEB)=Yes)
AND
((Master.[SENT TO PEB])=No) AND ((Master.TERMINATED)=No) AND
((Master.[No
Longer Tracking])=No) AND ((Master.BMIA)=No) AND
((Master.Transfer)=No)
AND
((Master.Other)=No) AND ((Master.TBTR)=No) AND
((Master.ADDENDUM)=No)
AND
((Master.SUS)=No));
I want to filter Master.[DATE SENT TO PEB] for both a date like I
did
in
Master.[Date of Board] and to include those entries which don't have
a
DATE
SENT TO PEB. After I get this query to display all of the
Master.[PEB]
cases
which meet the criteria of having been generated prior to Now()-21
(Master.[Date of Board], and have not been discharged prior to
Now()-21(Master.[DATE SENT TO PEB], including those that haven't
been
discharged Now(). The above SQL statement displays only those that
haven't
been discharged yet, vice having those that haven't been discharged
and
those
that weren't discharged prior to the date 3 weeks ago.