Here's a strange one... I have a query that works fine when I run it from the database. However when I execute it from VBA some of the columns don't return anything...
Code
With rsCmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdStoredProc
.CommandText = "qry_name"
.Parameters.Append .CreateParameter("@start", adDate, adParamInput)
.Parameters.Append .CreateParameter("@end", adDate, adParamInput)
.Parameters("@start").Value = CDate("01/01/2007")
.Parameters("@end").Value = CDate("01/04/2007")
End With
Set rsData = rsCmd.Execute
Query Snippet
SELECT qry_store_calls_by_period.store, tbl_stores.name AS store_name, tbl_stores_distribution.state, qry_store_calls_by_period_comms.communications...
FROM qry_store_calls_by_period LEFT JOIN tbl_stores ON qry_store_calls_by_period.store = tbl_stores.store...
WHERE...
The columns that are returning null are ones that are derived from a query joined to this query that do a count on the same table (based on different criteria).
So in summary when I run the query directly I get:
0501 abc 100 200 300 600
But when I run it through VBA i get:
0501 abc Null Null Null 600
The 600 (a sum) is returned in both instances... which is strange because it's doing the same thing as the other fields that are coming back Null. Would appreciate any light anyone can shed on this!!!
Tony
Code
With rsCmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdStoredProc
.CommandText = "qry_name"
.Parameters.Append .CreateParameter("@start", adDate, adParamInput)
.Parameters.Append .CreateParameter("@end", adDate, adParamInput)
.Parameters("@start").Value = CDate("01/01/2007")
.Parameters("@end").Value = CDate("01/04/2007")
End With
Set rsData = rsCmd.Execute
Query Snippet
SELECT qry_store_calls_by_period.store, tbl_stores.name AS store_name, tbl_stores_distribution.state, qry_store_calls_by_period_comms.communications...
FROM qry_store_calls_by_period LEFT JOIN tbl_stores ON qry_store_calls_by_period.store = tbl_stores.store...
WHERE...
The columns that are returning null are ones that are derived from a query joined to this query that do a count on the same table (based on different criteria).
So in summary when I run the query directly I get:
0501 abc 100 200 300 600
But when I run it through VBA i get:
0501 abc Null Null Null 600
The 600 (a sum) is returned in both instances... which is strange because it's doing the same thing as the other fields that are coming back Null. Would appreciate any light anyone can shed on this!!!
Tony