Is it possible to filter a table referenced in a query?

D

dv999

I have a lot of queries that reference the same table.
Now I have new criteria to filter for.
Instead of re-writing all of the queries, I would like to limit the tables
data before hand, so I can use the same queries.

This Database is live, so it becomes tricky.

Any ideas?
 
E

EeOr

Editing the queries sound like the best option.

One thing you could do although not recomended is rename the table and then
create one query that filters it and name that query what the original table
was called that way all other object will point to the query rather than the
table - just a thought, altho I am sure someone else will soon shoot this
idea down :eek:)!

Jon
 
D

dv999

That is in fact similar to what I did - I thought of it a little later on.
I did a string replacement on all the table names in the queries (40+
queries) with query names. I then created a few queries to replace those
tables.

I then added some parameters to give them options on the criteria/filter. It
seems to works fine in Access.

However, in Crystal reports when using these queries/views I get prompted
for a two extra parameters for some reason. (S.Site_cod and S.Patient_cod)

Extra parameter prompts in Crystal Reports as an ODBC connection.
--------------------------------------------------------
SELECT '1To3' AS Range,
SUM( IIF( (int_GoalImportance Between 1 And 3), 1, 0)) / Count(*) AS
PercentImportant,
SUM( IIF( (int_GoalConfidence Between 1 And 3), 1, 0)) / Count(*) AS
PercentConfident
FROM qryEncoded_HSFOHBPS_Serial AS S
WHERE ymd_VisitDate=
( SELECT Max( VisitDate )
FROM qrySitePatientVisit SPV
WHERE S.Site_cod = SPV.Site_cod
AND S.Patient_cod = SPV.Patient_cod
)
UNION
SELECT '4To6' AS Range,
SUM( IIF( (int_GoalImportance Between 4 And 6), 1, 0)) / Count(*) AS
PercentImportant,
SUM( IIF( (int_GoalConfidence Between 4 And 6), 1, 0)) / Count(*) AS
PercentConfident
FROM qryEncoded_HSFOHBPS_Serial AS S
WHERE ymd_VisitDate=
( SELECT Max( VisitDate )
FROM qrySitePatientVisit SPV
WHERE S.Site_cod = SPV.Site_cod
AND S.Patient_cod = SPV.Patient_cod
)
UNION SELECT '7Plus' AS Range,
SUM( IIF( (int_GoalImportance > 6), 1, 0)) / Count(*) AS PercentImportant,
SUM( IIF( (int_GoalConfidence > 6), 1, 0)) / Count(*) AS PercentConfident
FROM qryEncoded_HSFOHBPS_Serial AS S
WHERE ymd_VisitDate=
( SELECT Max( VisitDate )
FROM qrySitePatientVisit SPV
WHERE S.Site_cod = SPV.Site_cod
AND S.Patient_cod = SPV.Patient_cod
);
 
E

EeOr

Which version of Crystal are you using? I only have version 8 on this old
machine, are you sure you dont have any selection criteria set up within the
report that is asking for these values?

Jon
 
D

dv999

thanks for the tip.

I am using CR XI R2 SP1 (Crystal Reports 11 Release 2 Servcie Pack 1)
I create a new blank report, and CR stand-alone app. auto creates the
parameters with the same names as the params in access that I am asking for
in my queries, with no extra ones listed. (I am new to CR)

The query runs great in access but messes up in Crystal. Though one of the
parameters is a key field that is part of a join and maybe Crystal gets the
order of operations wrong...?
 
Top