I have an SQL query in VBA in which i'm trying to get the number of rows returned using the Count function...as below:
strSQL = "SELECT Count(*) As NumRows, DespatchRef, SupplierRef " & _
"FROM Despatches " & _
"WHERE DespDate = " & date1 & _
"AND (Shift = '" & shift1 & "');"
However, I'm getting the following run-time error:
"You tried to execute a query that does not include the specified expression 'DespatchRef' as part of an aggregate function"
If I remove the 'Count(*) As NumRows' bit, everything works fine...but i need to know the number of rows returns...what can i do?!
tnx
strSQL = "SELECT Count(*) As NumRows, DespatchRef, SupplierRef " & _
"FROM Despatches " & _
"WHERE DespDate = " & date1 & _
"AND (Shift = '" & shift1 & "');"
However, I'm getting the following run-time error:
"You tried to execute a query that does not include the specified expression 'DespatchRef' as part of an aggregate function"
If I remove the 'Count(*) As NumRows' bit, everything works fine...but i need to know the number of rows returns...what can i do?!
tnx