I checked everything, but the problem persists. This is the code:
Code:
Private Sub openreport_Click()
On Error GoTo Err_openreport_Click
Dim stDocName As String
Dim MyPath As String
Dim MyFilenamePDF As String
Dim MyFilenameRTF As String
MyPath = "C:\"
MyFilenamePDF = "rptBankStatement.pdf"
MyFilenameRTF = "rptBankStatement.rtf"
stDocName = "rptBankStatement"
If IsNull(cboMonth) Then
MsgBox "Please select month"
Else
If IsNull(Me.txtNetAmount) Then
MsgBox "Enter Net Salary"
Else
If Me.txtTotal > Me.txtNetAmount Then
MsgBox "The total amount to be credited is greater than net salary."
Else
DoCmd.openreport stDocName, acPreview
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilenamePDF, False
DoCmd.OutputTo acOutputReport, "", acFormatRTF, MyPath & MyFilenameRTF, False
MsgBox "Files saved in C:Drive"
End If
Exit Sub
End If
Exit Sub
End If
Exit Sub
Exit_openreport_Click:
Exit Sub
Err_openreport_Click:
MsgBox Err.Description
Resume Exit_openreport_Click
End Sub