I changed the query and it looks ok now however MS Access is changing the
query into another format once I save it overwriting my original Query.
Is there any way to take cre of it.
Thanks
Tanweer
SELECT tblhomeiv.*, Forms![Patient abx Report]!txtstartdate1 AS Expr2
FROM tblhomeiv
WHERE (((tblhomeiv.HOMEIVSTRDATE) Between [Forms]![Patient Abx
Report]![txtstartdate1] And [Forms]![Patient ABX Report]![txtstartdate2])
AND
((tblhomeiv.HOMEIVSTPDATE) Between [Forms]![Patient Abx
Report]![txtenddate1]
And [Forms]![Patient ABX Report]![txtenddate2]) AND
((tblhomeiv.patientid)=[Forms]![Patient abx Report]![cboPatient].[value]))
OR
(((tblhomeiv.HOMEIVSTRDATE) Between [Forms]![Patient Abx
Report]![txtstartdate1] And [Forms]![Patient ABX Report]![txtstartdate2])
AND
((tblhomeiv.HOMEIVSTPDATE) Between [Forms]![Patient Abx
Report]![txtenddate1]
And [Forms]![Patient ABX Report]![txtenddate2]) AND (([Forms]![Patient abx
Report]![cboPatient].[value]) Is Null)) OR (((tblhomeiv.HOMEIVSTPDATE)
Between [Forms]![Patient Abx Report]![txtenddate1] And [Forms]![Patient
ABX
Report]![txtenddate2]) AND ((tblhomeiv.patientid)=[Forms]![Patient abx
Report]![cboPatient].[value]) AND (([Forms]![Patient Abx
Report]![txtstartdate1]) Is Null)) OR (((tblhomeiv.HOMEIVSTPDATE) Between
[Forms]![Patient Abx Report]![txtenddate1] And [Forms]![Patient ABX
Report]![txtenddate2]) AND (([Forms]![Patient abx
Report]![cboPatient].[value]) Is Null) AND (([Forms]![Patient Abx
Report]![txtstartdate1]) Is Null)) OR (((tblhomeiv.HOMEIVSTRDATE) Between
[Forms]![Patient Abx Report]![txtstartdate1] And [Forms]![Patient ABX
Report]![txtstartdate2]) AND ((tblhomeiv.patientid)=[Forms]![Patient abx
Report]![cboPatient].[value]) AND (([Forms]![Patient Abx
Report]![txtenddate1]) Is Null)) OR (((tblhomeiv.HOMEIVSTRDATE) Between
[Forms]![Patient Abx Report]![txtstartdate1] And [Forms]![Patient ABX
Report]![txtstartdate2]) AND (([Forms]![Patient abx
Report]![cboPatient].[value]) Is Null) AND (([Forms]![Patient Abx
Report]![txtenddate1]) Is Null)) OR
(((tblhomeiv.patientid)=[Forms]![Patient
abx Report]![cboPatient].[value]) AND (([Forms]![Patient Abx
Report]![txtstartdate1]) Is Null) AND (([Forms]![Patient Abx
Report]![txtenddate1]) Is Null)) OR ((([Forms]![Patient abx
Report]![cboPatient].[value]) Is Null) AND (([Forms]![Patient Abx
Report]![txtstartdate1]) Is Null) AND (([Forms]![Patient Abx
Report]![txtenddate1]) Is Null));
Duane Hookom said:
There is no "start date" anywhere in your reply. When you place a value
in
txtstartdate1 are you also placing values in txtstartdate2, txtenddate1,
and
txtenddate2?
I think this gives you a better view of your current query:
SELECT tblhomeiv.*, Forms![Patient abx Report]!txtstartdate1 AS Expr2
FROM tblhomeiv
WHERE
(
patientid=[Forms]![Patient abx Report]![cboPatient].[value]
OR [Forms]![Patient abx Report]![cboPatient].[value] Is Null
)
AND
(
HOMEIVSTRDATE Between
[Forms]![Patient Abx Report]![txtstartdate1] And
[Forms]![Patient ABX Report]![txtstartdate2]
OR
[Forms]![Patient Abx Report]![txtstartdate1] Is Null
)
AND
(
HOMEIVSTPDATE Between
[Forms]![Patient Abx Report]![txtenddate1] And
[Forms]![Patient ABX Report]![txtenddate2]
OR
[Forms]![Patient Abx Report]![txtstartdate1] Is Null
);
--
Duane Hookom
MS Access MVP
--
Thanks for prompt reply
This does work for a single Selection criteria
However when I put multiple criteria I am doomed
Here is the final query which not worked If I put more than one
selection
criteria it does not pull any thing
however if I just put patient id it worked however when I add also
Start
date criteria it pull nothing.
SELECT tblhomeiv.*, tblhomeiv.patientid, tblhomeiv.HOMEIVSTRDATE,
tblhomeiv.HOMEIVSTPDATE, Forms![Patient abx Report]!txtstartdate1 AS
Expr2
FROM tblhomeiv
WHERE ((tblhomeiv.patientid=[Forms]![Patient abx
Report]![cboPatient].[value]) OR ([Forms]![Patient abx
Report]![cboPatient].[value] Is Null))
AND ((tblhomeiv.HOMEIVSTRDATE Between [Forms]![Patient Abx
Report]![txtstartdate1] And [Forms]![Patient ABX
Report]![txtstartdate2])
OR
([Forms]![Patient Abx Report]![txtstartdate1] Is Null))
AND ((tblhomeiv.HOMEIVSTPDATE Between [Forms]![Patient Abx
Report]![txtenddate1] And [Forms]![Patient ABX Report]![txtenddate2])
OR
([Forms]![Patient Abx Report]![txtstartdate1] Is Null));
Thanks
Tanweer
:
You criteria should be something like:
Patient_ID = [Forms]![Patient abx Report]![cboPatient] Or
[Forms]![Patient
abx Report]![cboPatient] Is Null
If this query is for display in a form or report (is there anything
else)
then I would not place any of these criteria in the query.
--
Duane Hookom
MS Access MVP
--
Please help I am stuck.
I have a form which has three field to pass and what I want to do is
if
user
don't select any thing I want to shwo every thing but if they select
patient
id only show that opatient record
and if they select a date criteria then show only that patient
record
with
start date in the range selected.
Here is the for look like
Patient_id ______
Start Date ________ through ________
End Date _________ through _________
When I pass it to the Query I put in the criteria field
patient_id Is Not Null And [Forms]![Patient abx
Report]![cboPatient].[value]
in the column Start Date in the same and line I put
Is Not Null And Between [Forms]![Patient Abx Report]![txtstartdate1]
And
[Forms]![Patient ABX Report]![txtstartdate2]
In the Column End Date in the same AND line I put
Is Not Null And Between [Forms]![Patient abx Report]![txtenddate1]
And
[Forms]![Patient abx Report]![txtenddate2]
However I am not seeign any record coming up what I am doing wrong
Will approeciate for any suggestion or answer.
Thanks
Tanweer