aziz rasul
06-19-2006, 08:11 AM
I have an MS Access report in which I go thru a recordset to change the Record Source of the report. I wish to export the report as SNP files as it goes thru the recordset. I have tried doing using a button on a form.
At the moment it comes up with an error saying it doesn't recognise the name of the report. How do I export the report once this is solved?
Any help would be appreciated.
Private Sub cmdExportReports_Click()
Dim strSQL As String
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblVarianceRanges", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
With rst
strSQL = "SELECT qAzizVarianceComensura3.[Candidate ID Number], "
strSQL = strSQL & "qAzizVarianceComensura3.Name, "
strSQL = strSQL & "qAzizVarianceComensura3.[Week Ending], "
strSQL = strSQL & "qAzizVarianceComensura3.[Tempest Gross], "
strSQL = strSQL & "qAzizVarianceComensura3.[Client Gross], "
strSQL = strSQL & "qAzizVarianceComensura3.Variance, "
strSQL = strSQL & "qAzizVarianceComensura3.AbsValue "
strSQL = strSQL & "FROM qAzizVarianceComensura3 "
strSQL = strSQL & "WHERE (((qAzizVarianceComensura3.Variance) " & !VarianceRange & ")) "
strSQL = strSQL & "ORDER BY qAzizVarianceComensura3.Variance;"
Reports!rptVarianceComensura.RecordSource = strSQL 'Error 2451 here.
DoCmd.OpenReport "rptVarianceComensura", acViewPreview
.MoveNext
End With
Loop
End Sub
At the moment it comes up with an error saying it doesn't recognise the name of the report. How do I export the report once this is solved?
Any help would be appreciated.
Private Sub cmdExportReports_Click()
Dim strSQL As String
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblVarianceRanges", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
With rst
strSQL = "SELECT qAzizVarianceComensura3.[Candidate ID Number], "
strSQL = strSQL & "qAzizVarianceComensura3.Name, "
strSQL = strSQL & "qAzizVarianceComensura3.[Week Ending], "
strSQL = strSQL & "qAzizVarianceComensura3.[Tempest Gross], "
strSQL = strSQL & "qAzizVarianceComensura3.[Client Gross], "
strSQL = strSQL & "qAzizVarianceComensura3.Variance, "
strSQL = strSQL & "qAzizVarianceComensura3.AbsValue "
strSQL = strSQL & "FROM qAzizVarianceComensura3 "
strSQL = strSQL & "WHERE (((qAzizVarianceComensura3.Variance) " & !VarianceRange & ")) "
strSQL = strSQL & "ORDER BY qAzizVarianceComensura3.Variance;"
Reports!rptVarianceComensura.RecordSource = strSQL 'Error 2451 here.
DoCmd.OpenReport "rptVarianceComensura", acViewPreview
.MoveNext
End With
Loop
End Sub