I am upgrading a database from Access 2000 to Access 2010
In Access 2000, to filter a report I used the following:
Wclause = "InvoiceId = " & Me.lstSelectInvoice.Column(1)
DoCmd.OpenReport "rptCustomerTaxInvoice", acViewPreview, , WClause
This worked well!
I now want to use the Access 2010 feature of printing to pdf.
To do this I need to use the following:
Wclause = "InvoiceId = " & Me.lstSelectInvoice.Column(1)
DoCmd.OutputTo acOutputReport, "rptCustomerTaxInvoice", acFormatPDF, "C:\CustomerTaxInvoice.pdf", False, , , acExportQualityPrint
but the DoCmd line does not allow me to include the "Wclause" as a "where" statement!
to overcome this I have added the following event to my report:
Private Sub Report_Open(Cancel As Integer)
If Wclause <> "" Then
Me.Filter = Wclause
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub
However when I run the code, Access returns an error:
Run Time Error '3000'
Reserved error (-1524), there is no message for this error
If I change Wclause to Wclause = "" then the report runs. This is good news because it tells me that there is nothing wrong with the report or its data!
What am I doing wrong!!!!
Thanks in advance
In Access 2000, to filter a report I used the following:
Wclause = "InvoiceId = " & Me.lstSelectInvoice.Column(1)
DoCmd.OpenReport "rptCustomerTaxInvoice", acViewPreview, , WClause
This worked well!
I now want to use the Access 2010 feature of printing to pdf.
To do this I need to use the following:
Wclause = "InvoiceId = " & Me.lstSelectInvoice.Column(1)
DoCmd.OutputTo acOutputReport, "rptCustomerTaxInvoice", acFormatPDF, "C:\CustomerTaxInvoice.pdf", False, , , acExportQualityPrint
but the DoCmd line does not allow me to include the "Wclause" as a "where" statement!
to overcome this I have added the following event to my report:
Private Sub Report_Open(Cancel As Integer)
If Wclause <> "" Then
Me.Filter = Wclause
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub
However when I run the code, Access returns an error:
Run Time Error '3000'
Reserved error (-1524), there is no message for this error
If I change Wclause to Wclause = "" then the report runs. This is good news because it tells me that there is nothing wrong with the report or its data!
What am I doing wrong!!!!
Thanks in advance