Select Case frm.fraOutputTo
Case 1 'open form
If rs!DisplayType = "Report" Then 'some selections can only be displayed as reports
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
Else
stDocName = frm.txtFormToOpen
frm.Visible = False
DoCmd.OpenForm stDocName, , , , , acWindowNormal, frm.Name
End If
Case 2 'preview report
If rs!DisplayType = "Form" Then 'some selections can only be displayed as forms
stDocName = frm.txtFormToOpen
frm.Visible = False
DoCmd.OpenForm stDocName, , , , , acWindowNormal, frm.Name
Else
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
End If
Case 3 'print report
If rs!DisplayType = "Form" Then 'some selections can only be displayed as forms
stDocName = frm.txtFormToOpen
frm.Visible = False
DoCmd.OpenForm stDocName, , , , , acWindowNormal, frm.Name
Else
DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria
End If
Case 4 'export to Excel
If IsNull(rs!exportquery) Then '
MsgBox "Export is not available for this report.", vbOKOnly + vbInformation
Else
' ThisDBPath = Left(CodeDb.Name, InStrRev(CodeDb.Name, "\"))
' ExportFileName = ThisDBPath & Forms!frmLogin!cboAuditParmsID.Column(4)
DoCmd.OpenForm "frmGetDirectory2", acNormal, , , , acDialog
ExportFileName = Forms!frmLogin!txtPath
If ExportFileName & "" = "" Then
MsgBox "Path name was not provided. Export cancelled.", vbOKOnly + vbCritical
rs.Close
GoTo lstReports_DblClick_Exit
End If
ExportFileName = ExportFileName & "-" & rs!ExportFileName & "-" & Format(Date, "yymmdd") & ".XLS"
If Dir(ExportFileName) <> "" Then Kill ExportFileName
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, rs!exportquery, ExportFileName, True
MsgBox "File Exported to ---> " & ExportFileName, vbOKOnly + vbInformation
End If
Case 5 ' pdf
DoCmd.OpenForm "frmGetDirectory2", acNormal, , , , acDialog
ExportFileName = Forms!frmLogin!txtPath
If ExportFileName & "" = "" Then
MsgBox "Path name was not provided. Export cancelled.", vbOKOnly + vbCritical
rs.Close
GoTo lstReports_DblClick_Exit
End If
ExportFileName = ExportFileName & "-" & rs!ExportFileName & "-" & Format(Date, "yymmdd") & ".pdf"
If Dir(ExportFileName) <> "" Then Kill ExportFileName
'DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, rs!ExportQuery, ExportFileName, True
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, ExportFileName, False
MsgBox "File Exported to ---> " & ExportFileName, vbOKOnly + vbInformation
Case Else ' no output type selected
MsgBox "Please select an output type.", vbOKOnly + vbInformation
Exit Sub
End Select