2008-09-30 58 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