G
Guest
Running Access 2003.
We have a query linked to an SQL Server database and a report using this
query. The query runs in only a few seconds. The report, when run directly
from the database window, also takes just a few seconds. But when the report
is run from VBA, because we usually want data for a specific period of time
and for a specific client, the report may take as long as two hours.
The report is run by the following command:
DoCmd.OpenReport stDocName, acPreview, , "clientname ='" & Me.cmbClientName
& "' AND cdate(TransferDateF) between cdate('" & Me.txtFra & "') AND cdate('"
& Me.txtTil & "') "
I guess the WhereCondition is the problem here. But the query is sorted on
both ClientName and TransferDateF, so I see no reason why it should take that
long to run.
Why is this taking so long? And what can we do to make it run faster?
We have a query linked to an SQL Server database and a report using this
query. The query runs in only a few seconds. The report, when run directly
from the database window, also takes just a few seconds. But when the report
is run from VBA, because we usually want data for a specific period of time
and for a specific client, the report may take as long as two hours.
The report is run by the following command:
DoCmd.OpenReport stDocName, acPreview, , "clientname ='" & Me.cmbClientName
& "' AND cdate(TransferDateF) between cdate('" & Me.txtFra & "') AND cdate('"
& Me.txtTil & "') "
I guess the WhereCondition is the problem here. But the query is sorted on
both ClientName and TransferDateF, so I see no reason why it should take that
long to run.
Why is this taking so long? And what can we do to make it run faster?