Cómo filtrar un objeto de informe al guardar a través de FileDialog en MS Access
-
03-07-2019 - |
Pregunta
Estoy intentando guardar un archivo rtf usando FileDialog y me gustaría filtrar usando una cláusula where. Esto es lo que tengo:
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
¿Alguna idea sobre cómo podría agregar la cláusula where sin cambiar el informe?
Solución
Descubrí que la forma más sencilla de hacer esto sin tocar el código del informe en sí es abrir el informe en modo de vista previa con el filtro aplicado y luego enviar el informe al formato que sea necesario.
If .Show Then
DoCmd.OpenReport Me.cmbPickAReportToPrint.Value, acViewPreview, , "fieldToFilterOn = 'value'"
DoCmd.OutputTo acOutputReport, Me.cmbPickAReportToPrint.Value, acFormatRTF, .SelectedItems(1)
End If
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow