C
Cynthia
Guest
Hello!
I need help, please, with printing an Access report from VB5.
I need to accomplish two things before the report is printed: 1) I need to change the caption of a label (lblDetail) on the report based on a user's selection. 2) I need to append a where clause to the SQL statement that is the report's Record Source (where clause is based on user's selection).
I seem to be able to do one or the other, so I know that the syntax is alright. But the way it is now, the label caption is changed but the SQL where clause is ignored.
There must be a way!! Here's my code, followed by the SQL statement that the Report is based on.
Thanks for any help!
Cynthia
(dRequest is RequestNumber user chose.)
SQLwhereClause= "ILL.REQUEST = " & dRequest
Static accApp As New Access.Application
With accApp
.OpenCurrentDatabase (gsDatabase)
.Visible = False
.DoCmd.OpenReport "MyReport", acViewDesign, , SQLwhereClause
.Reports("MyReport").lblDetail.Caption = sDetail
.DoCmd.OpenReport "MyReport", acViewPreview, , SQLwhereClause
.DoCmd.Close
End With
Report.RecordSource's SQL statement:
SELECT ILL.REQUEST, ILL.PATRON, ILL.LIBRARY, LIBRARIES.ILLCODE, LIBRARIES.PHONE, LIBRARIES.FAX, FROM LIBRARIES INNER JOIN ILL ON LIBRARIES.ILLCODE = ILL.LIBRARY;
I need help, please, with printing an Access report from VB5.
I need to accomplish two things before the report is printed: 1) I need to change the caption of a label (lblDetail) on the report based on a user's selection. 2) I need to append a where clause to the SQL statement that is the report's Record Source (where clause is based on user's selection).
I seem to be able to do one or the other, so I know that the syntax is alright. But the way it is now, the label caption is changed but the SQL where clause is ignored.
There must be a way!! Here's my code, followed by the SQL statement that the Report is based on.
Thanks for any help!
Cynthia
(dRequest is RequestNumber user chose.)
SQLwhereClause= "ILL.REQUEST = " & dRequest
Static accApp As New Access.Application
With accApp
.OpenCurrentDatabase (gsDatabase)
.Visible = False
.DoCmd.OpenReport "MyReport", acViewDesign, , SQLwhereClause
.Reports("MyReport").lblDetail.Caption = sDetail
.DoCmd.OpenReport "MyReport", acViewPreview, , SQLwhereClause
.DoCmd.Close
End With
Report.RecordSource's SQL statement:
SELECT ILL.REQUEST, ILL.PATRON, ILL.LIBRARY, LIBRARIES.ILLCODE, LIBRARIES.PHONE, LIBRARIES.FAX, FROM LIBRARIES INNER JOIN ILL ON LIBRARIES.ILLCODE = ILL.LIBRARY;