H
helpseeker
Hello.
I am using Access2000
Report rptPrintLabels uses a query qryLabelData as recordsource.
rptPrintLabels: Filter = Yes
qryLabelData uses multiple functions.
When this report is printed by itself, all records are printed.
This report can also be called from - usually to print one label, where I
use this syntax:
stDocName = "rptPrintLabels"
StrFilter = "Select * from qryLabelData where ID = " & Me.txtID
DoCmd.OpenReport stDocName, acViewPreview, StrFilter
Report_open event:
intRecs = DCount("[ID]", Me.RecordSource)
If intRecs < 1 Then
MsgBox "No Records found. Cancelling report", vbOKOnly + vbInformation,
"Cannot run Report"
Cancel = True
Else
....
End If
When the report is called from the form only one record is displayed (as
expected)
All of this works fine, EXCEPT that I have noticed the following:
1. for the DCount statement, the entire query is executed, complete with all
function calls (ignoring the filter)
2. After the Report Open and before Detail_Print Event, the entire query is
run again.
Question:
If possible, I'd like to eliminate this double execution of the entire
query - unnecessary processing and resulting delay
Me.RecordCount and Me.RecordSetClone are not available
I'd rather not create a copy of qryLabelData with a criteria of
Forms!...txtID as I would have to create multiple such queries because I'd
like to have a single point of maintenence.
Thanks in advance for the assistance.
I am using Access2000
Report rptPrintLabels uses a query qryLabelData as recordsource.
rptPrintLabels: Filter = Yes
qryLabelData uses multiple functions.
When this report is printed by itself, all records are printed.
This report can also be called from - usually to print one label, where I
use this syntax:
stDocName = "rptPrintLabels"
StrFilter = "Select * from qryLabelData where ID = " & Me.txtID
DoCmd.OpenReport stDocName, acViewPreview, StrFilter
Report_open event:
intRecs = DCount("[ID]", Me.RecordSource)
If intRecs < 1 Then
MsgBox "No Records found. Cancelling report", vbOKOnly + vbInformation,
"Cannot run Report"
Cancel = True
Else
....
End If
When the report is called from the form only one record is displayed (as
expected)
All of this works fine, EXCEPT that I have noticed the following:
1. for the DCount statement, the entire query is executed, complete with all
function calls (ignoring the filter)
2. After the Report Open and before Detail_Print Event, the entire query is
run again.
Question:
If possible, I'd like to eliminate this double execution of the entire
query - unnecessary processing and resulting delay
Me.RecordCount and Me.RecordSetClone are not available
I'd rather not create a copy of qryLabelData with a criteria of
Forms!...txtID as I would have to create multiple such queries because I'd
like to have a single point of maintenence.
Thanks in advance for the assistance.