Reputation: 23
When I run the below code I get an error "Object Required". I want to be able to click a button and it will save this file along with a numerical field on the report known as Market_ID
, then name of the report is Market Rate Notification Final. The report does show up but I do not get a save dialog box. Also if I remove
Report![Market Rate Notification Final].Market_ID +
from strReportName
I get a save dialog box with the file prenamed as Market Rate Notification Final.pdf.
Option Compare Database
'------------------------------------------------------------
' Export_MLR
'
'------------------------------------------------------------
Function Export_MLR()
On Error GoTo Export_MLR_Err
Dim strReportName As String
strReportName = Report![Market Rate Notification Final].Market_ID + "Market Rate Notification Final"
DoCmd.OutputTo acOutputReport, strReportName, "PDFFormat(*.pdf)", "", False, "", , acExportQualityScreen
Export_MLR_Exit:
Exit Function
Export_MLR_Err:
MsgBox Error$
Resume Export_MLR_Exit
End Function
Upvotes: 0
Views: 906
Reputation: 91366
You cannot refer to the contents of a report control like this:
strReportName = _
Report![Market Rate Notification Final].Market_ID + "Market Rate Notification Final"
The result of the various errors is that strReportName is Null. First, it is Reports
, not Report
, next, you cannot get the value of a control in this way from a report, what you will get is the value of the last row of the report, and the concatenator is & not +, unless you are doing something quite fancy.
Upvotes: 1