S
scott
I have a button that prints a report with a filter, but when it prints the
report, it ignores the filter. I had messier code worked (it changed the
record source before printing, but that meant it had to open the form in
design, change the record source, go back to print preview and then print)
which I tried to clean up, but I am now stuck on this.
stLinkCriteria = "[All Data].Projsub= " & Forms![Main Menu]![Field5] & " AND
[All Data].Perpost>= '" & Forms![Main Menu]![Field29] & "' And [All
Data].Perpost<= '" & Forms![Main Menu]![Field81] & "'"
stReport = "By Line Item2"
DoCmd.OpenReport stReport, acViewPreview
Reports![By Line Item2].Filter = stLinkCriteria
DoCmd.RunCommand acCmdPrint
report, it ignores the filter. I had messier code worked (it changed the
record source before printing, but that meant it had to open the form in
design, change the record source, go back to print preview and then print)
which I tried to clean up, but I am now stuck on this.
stLinkCriteria = "[All Data].Projsub= " & Forms![Main Menu]![Field5] & " AND
[All Data].Perpost>= '" & Forms![Main Menu]![Field29] & "' And [All
Data].Perpost<= '" & Forms![Main Menu]![Field81] & "'"
stReport = "By Line Item2"
DoCmd.OpenReport stReport, acViewPreview
Reports![By Line Item2].Filter = stLinkCriteria
DoCmd.RunCommand acCmdPrint