2008-09-30 57 views
3

節省我試圖保存使用FileDialog的RTF文件,並想使用WHERE子句來篩選時如何過濾報表對象。這是我有什麼:通過的FileDialog在MS Access

Set dlgSave = FileDialog(msoFileDialogSaveAs) 
With dlgSave 
    .Title = "Provide the place to save this file" 
    .ButtonName = "Save As..." 
    .InitialFileName = Me.cmbPickAReportToPrint.Value & "-" & Format(Date, "mmddyy") & ".rtf" 
    .InitialView = msoFileDialogViewDetails 

    If .Show Then 
     DoCmd.OutputTo acOutputReport, Me.cmbPickAReportToPrint.Value, acFormatRTF, .SelectedItems(1) 
    End If 
End With 

任何想法如何我可以添加where子句,而無需另外更改報告?

回答

3

我發現,這樣做沒有觸及報告代碼本身最簡單的方法是應用了過濾器,以打開在預覽模式下的報表,然後輸出到你需要的任何格式的報表。

If .Show Then 
    DoCmd.OpenReport Me.cmbPickAReportToPrint.Value, acViewPreview, , "fieldToFilterOn = 'value'" 
    DoCmd.OutputTo acOutputReport, Me.cmbPickAReportToPrint.Value, acFormatRTF, .SelectedItems(1) 
End If