views:

358

answers:

1

I am attempting to save an rtf file using FileDialog and would like to filter using a where clause. This is what I have:

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

Any ideas as to how I could add the where clause without otherwise changing the report?

+3  A: 

I've found that the easiest way to do this without touching the report code itself is to open the report in preview mode with the filter applied, and then output the report to whatever format you need.

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