crisis2007
Technical User
I have the following code on a button. I cannot figure out why I get a Type Mismatch error message when I try it. Can anyone see what is wrong with what I have here? I am just trying to save a report to PDF in the specified file. Eventually I am going to want it to take textbox values from the report as the name of the PDF when it is saved. But I cannot get this to even work.
Private Sub Command187_Click()
On Error GoTo Err_Command187_Click
Dim stDocName As String
TheFile = "C:\Documents and Settings\jdoe\Desktop\ActivityPDF\"
stDocName = "R_MasterWatch"
DoCmd.OpenReport stDocName, acPreview
DoCmd.OutputTo acFormatPDF, stDocName, TheFile, False, ""
TheMessage = "Report has been save to " & TheFile
Beep
MsgBox TheMessage, vbInformation, "Report Saved"
Exit_Command187_Click:
Exit Sub
Err_Command187_Click:
MsgBox Err.Description
Resume Exit_Command187_Click
End Sub
Private Sub Command187_Click()
On Error GoTo Err_Command187_Click
Dim stDocName As String
TheFile = "C:\Documents and Settings\jdoe\Desktop\ActivityPDF\"
stDocName = "R_MasterWatch"
DoCmd.OpenReport stDocName, acPreview
DoCmd.OutputTo acFormatPDF, stDocName, TheFile, False, ""
TheMessage = "Report has been save to " & TheFile
Beep
MsgBox TheMessage, vbInformation, "Report Saved"
Exit_Command187_Click:
Exit Sub
Err_Command187_Click:
MsgBox Err.Description
Resume Exit_Command187_Click
End Sub