D
david.malcolm
Hi
I have a query about a query (!) which simply calculates a total and
works fine as the RecordSource for a report.
SELECT Count(lngRequestId) AS CountOflngRequestId
FROM tblRequests
WHERE (((dtmRequestRequestedDate) Between #01/01/2007# And
#01/31/2007#) AND (([lngRequestI]+[lngRequestIC]+[lngRequestVG]+
[lngRequestVC]+[lngRequestEG]+[lngRequestEC]+[lngRequestVP]+
[lngRequestCR])=0));
I wish to set this where condition when I run the report so I have
changed the query so there is no Where clause and then constructed the
Where clause and tried to use it with the WhereCondition of
DoCmd.OpenReport
The Query is now..
SELECT Count(lngRequestId) AS CountOflngRequestId
FROM tblRequests;
However when I try to set the WhereCondition clause using
DoCmd.OpenReport "rptName", acViewPreview ,, strSQL
I get prompted for all the fields in my Where condition as if they do
not exist in the database and my report does not run. My
WhereCondition strSQL is constructed correctly as far as I can tell...
strSQL = "(((dtmRequestRequestedDate) Between #01/01/2007# And
#01/31/2007#) AND "
strSQL = strSQL & "(([lngRequestI]+[lngRequestIC]+[lngRequestVG]+
[lngRequestVC]+[lngRequestEG]"
strSQL = strSQL & "+[lngRequestEC]+[lngRequestVP]+[lngRequestCR])=0))"
Is anyone aware of a problem with the WhereCondition when using
OpenReport. I can understand that the fields in my Where clause are
not mentioned as part of the Select statement, but the query works if
they are all together in the query itself, so why does it not work
when I separate them? I have tried this with simpler reports that do
not use an aggregate function and wonder if this is a restriction on
using the WhereCondition with the OpenReport command? Can someone
please advise if this can be done or if it is not possible at all?
Thanks
I have a query about a query (!) which simply calculates a total and
works fine as the RecordSource for a report.
SELECT Count(lngRequestId) AS CountOflngRequestId
FROM tblRequests
WHERE (((dtmRequestRequestedDate) Between #01/01/2007# And
#01/31/2007#) AND (([lngRequestI]+[lngRequestIC]+[lngRequestVG]+
[lngRequestVC]+[lngRequestEG]+[lngRequestEC]+[lngRequestVP]+
[lngRequestCR])=0));
I wish to set this where condition when I run the report so I have
changed the query so there is no Where clause and then constructed the
Where clause and tried to use it with the WhereCondition of
DoCmd.OpenReport
The Query is now..
SELECT Count(lngRequestId) AS CountOflngRequestId
FROM tblRequests;
However when I try to set the WhereCondition clause using
DoCmd.OpenReport "rptName", acViewPreview ,, strSQL
I get prompted for all the fields in my Where condition as if they do
not exist in the database and my report does not run. My
WhereCondition strSQL is constructed correctly as far as I can tell...
strSQL = "(((dtmRequestRequestedDate) Between #01/01/2007# And
#01/31/2007#) AND "
strSQL = strSQL & "(([lngRequestI]+[lngRequestIC]+[lngRequestVG]+
[lngRequestVC]+[lngRequestEG]"
strSQL = strSQL & "+[lngRequestEC]+[lngRequestVP]+[lngRequestCR])=0))"
Is anyone aware of a problem with the WhereCondition when using
OpenReport. I can understand that the fields in my Where clause are
not mentioned as part of the Select statement, but the query works if
they are all together in the query itself, so why does it not work
when I separate them? I have tried this with simpler reports that do
not use an aggregate function and wonder if this is a restriction on
using the WhereCondition with the OpenReport command? Can someone
please advise if this can be done or if it is not possible at all?
Thanks