G
Guest
I have 20 reports based on different tables in my db each of these reports
can be run from 3 different queries depending on what selection criteria the
user needs.
I want to use an object(report) variable to change the RecordSource property
and then print the report this is the code I have so far
*************
Select Case fraAudit.Value
Case 1 ' All
strAuditRepType = "All"
Case 2 ' By User Id
strAuditRepType = "UserID"
Case 3 ' By Staff Number
strAuditRepType = "StaffNo"
End Select
Dim strQryName As String
Dim intCount As Integer
Dim objReport As Report
For intCount = 1 To 20
strQryName = "qryrptAudit" & strTableNames(intCount) & strAuditRepType
Set objReport = "rptAudit" & strTableNames(intCount) '<<<<<<<<<<<<<<
objReport.RecordSource = strQryName
DoCmd.OpenReport objReport.Name, acViewPreview
Next intCount
*********************
My problem is the line I've indicated with <<<<<<<<<<<<<<< gives me a type
mismatch error
Can someone tell me what the correct syntax / method is for assigning an
object varaible to a string?
Thanks
Simon
can be run from 3 different queries depending on what selection criteria the
user needs.
I want to use an object(report) variable to change the RecordSource property
and then print the report this is the code I have so far
*************
Select Case fraAudit.Value
Case 1 ' All
strAuditRepType = "All"
Case 2 ' By User Id
strAuditRepType = "UserID"
Case 3 ' By Staff Number
strAuditRepType = "StaffNo"
End Select
Dim strQryName As String
Dim intCount As Integer
Dim objReport As Report
For intCount = 1 To 20
strQryName = "qryrptAudit" & strTableNames(intCount) & strAuditRepType
Set objReport = "rptAudit" & strTableNames(intCount) '<<<<<<<<<<<<<<
objReport.RecordSource = strQryName
DoCmd.OpenReport objReport.Name, acViewPreview
Next intCount
*********************
My problem is the line I've indicated with <<<<<<<<<<<<<<< gives me a type
mismatch error
Can someone tell me what the correct syntax / method is for assigning an
object varaible to a string?
Thanks
Simon