通过MS Access中的FileDialog保存时如何过滤报表对象
时间:2020-03-06 14:56:07 来源:igfitidea点击:
我正在尝试使用FileDialog保存rtf文件,并希望使用where子句进行过滤。这就是我所拥有的:
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子句而不更改报告的任何想法?
解决方案
我发现,最简单的方法而不触及报告代码本身,就是在预览模式下应用过滤器打开报告,然后将报告输出为所需的任何格式。
If .Show Then DoCmd.OpenReport Me.cmbPickAReportToPrint.Value, acViewPreview, , "fieldToFilterOn = 'value'" DoCmd.OutputTo acOutputReport, Me.cmbPickAReportToPrint.Value, acFormatRTF, .SelectedItems(1) End If