D
DDBeards
I have a program that allows the user to select a report from a drop down
that is followed by a filter option window that I have used and it works
great. However this new project requires that each of the reports have the
option to be exported to excel. In the past I have used the following code
with just the first two Cases. stDocName is the name of the report set by the
dropdown and sFilter is the requested filter built by the users selections.
My problem is Case 3! This will do just what I want accept I can not pass it
the filter, so all the records are moved, not the filtered list. Please help.
Select Case SpitWhat 'Output Type
Case Is = 1 'Preview
DoCmd.OpenReport stDocName, acViewPreview, , sFilter,
acWindowNormal
Case Is = 2 'Print
DoCmd.OpenReport stDocName, acNormal, , sFilter, acWindowNormal
Case Is = 3 'Excel
DoCmd.SetWarnings False
DoCmd.OutputTo acOutputReport, stDocName,
"MicrosoftExcelBiff8(*.xls)", "", True, "", 0
DoCmd.SetWarnings True
End Select
Thanks in advance, Chris
that is followed by a filter option window that I have used and it works
great. However this new project requires that each of the reports have the
option to be exported to excel. In the past I have used the following code
with just the first two Cases. stDocName is the name of the report set by the
dropdown and sFilter is the requested filter built by the users selections.
My problem is Case 3! This will do just what I want accept I can not pass it
the filter, so all the records are moved, not the filtered list. Please help.
Select Case SpitWhat 'Output Type
Case Is = 1 'Preview
DoCmd.OpenReport stDocName, acViewPreview, , sFilter,
acWindowNormal
Case Is = 2 'Print
DoCmd.OpenReport stDocName, acNormal, , sFilter, acWindowNormal
Case Is = 3 'Excel
DoCmd.SetWarnings False
DoCmd.OutputTo acOutputReport, stDocName,
"MicrosoftExcelBiff8(*.xls)", "", True, "", 0
DoCmd.SetWarnings True
End Select
Thanks in advance, Chris