gojets1721
Registered User.
- Local time
- Today, 02:18
- Joined
- Jun 11, 2019
- Messages
- 430
Probably a very stupid question, but I have an export command on a report and I changed it to Option Explicit.
When doing so it's saying the bolded 'currentreport' below is not defined. I'm not sure what to define it as. That line identifies the open report's name.
Any suggestions?
When doing so it's saying the bolded 'currentreport' below is not defined. I'm not sure what to define it as. That line identifies the open report's name.
Any suggestions?
Code:
Private Sub btnExportReport_Click()
On Error GoTo btnExportReport_Click_Err
Dim fd As Object
Dim FileName As String
Dim ReportName As String
ReportName = Reports(currentreport).Name
Set fd = Application.FileDialog(2)
FileName = Complaint History" & " " & Format(Date, "mm.dd.yyyy") & ".pdf"
With fd
.Title = "Save to PDF"
.InitialFileName = "\Documents\" & FileName
If .Show = -1 Then
FileName = fd.selecteditems(1)
If Right(FileName, 4) <> ".pdf" Then
FileName = FileName & ".pdf"
End If
DoCmd.OutputTo acOutputReport, ReportName, acFormatPDF, FileName
MsgBox "Report saved to " & FileName
End If
End With
btnExportReport_Click_Exit:
Set fd = Nothing
Exit Sub
btnExportReport_Click_Err:
MsgBox "Error #" & Err.Number & " - " & Err.Description, , "Error"
Resume btnExportReport_Click_Exit
End Sub