M
madhouse
Hi
I hope someone can help,this is driving me mad...
I have an SQL statement that returns no records when executed in VBA with an
ADO open statement. The identical SQL (copied out of the SQL variable at run
time to be sure!) returns 1 record when executed as a direct SQL query in
queries!
aaaagggghhhh!
VBA code is:
SQL = "SELECT Count(ProFormaHdr.ProFormaID) as HowMany " & _
"FROM (ProFormaHdr INNER JOIN Company ON ProFormaHdr.CoID = Company.CoID)
Where " & _
strGlobalWhereClause & " and ProFormaHdr.ProFormaProducedDate is not NULL; "
ProFormaHdrData.Open SQL, Cnxn, adOpenForwardOnly, adLockOptimistic
HowMany = ProFormaHdrData!HowMany
HowMany is zero. If the Count is removed from the SQL, an empty recordset is
returned.
The value of the SQL variable is:
SELECT Count(ProFormaHdr.ProFormaID) as HowMany FROM (ProFormaHdr INNER JOIN
Company ON ProFormaHdr.CoID = Company.CoID) Where (( Company.CoName Like
"*DES*") OR ( Company.Soundex Like "DZ*")) AND
ProFormaHdr.ProFormaProducedDate is not NULL AND ProFormaHdr.ProFormaID in
(Select ProFormaItem.ProFormaID from ProFormaItem where ProFormaItem.ProdID
= 2) and ProFormaHdr.ProFormaProducedDate is not NULL;
This returns HowMany with value of 1 when run directly in queries.
The data tables are the same in both cases.
I must be missing something. Please please help
Thanks
Madhouse
I hope someone can help,this is driving me mad...
I have an SQL statement that returns no records when executed in VBA with an
ADO open statement. The identical SQL (copied out of the SQL variable at run
time to be sure!) returns 1 record when executed as a direct SQL query in
queries!
aaaagggghhhh!
VBA code is:
SQL = "SELECT Count(ProFormaHdr.ProFormaID) as HowMany " & _
"FROM (ProFormaHdr INNER JOIN Company ON ProFormaHdr.CoID = Company.CoID)
Where " & _
strGlobalWhereClause & " and ProFormaHdr.ProFormaProducedDate is not NULL; "
ProFormaHdrData.Open SQL, Cnxn, adOpenForwardOnly, adLockOptimistic
HowMany = ProFormaHdrData!HowMany
HowMany is zero. If the Count is removed from the SQL, an empty recordset is
returned.
The value of the SQL variable is:
SELECT Count(ProFormaHdr.ProFormaID) as HowMany FROM (ProFormaHdr INNER JOIN
Company ON ProFormaHdr.CoID = Company.CoID) Where (( Company.CoName Like
"*DES*") OR ( Company.Soundex Like "DZ*")) AND
ProFormaHdr.ProFormaProducedDate is not NULL AND ProFormaHdr.ProFormaID in
(Select ProFormaItem.ProFormaID from ProFormaItem where ProFormaItem.ProdID
= 2) and ProFormaHdr.ProFormaProducedDate is not NULL;
This returns HowMany with value of 1 when run directly in queries.
The data tables are the same in both cases.
I must be missing something. Please please help
Thanks
Madhouse