I have a button that opens a report via VBA code.
,
where strFilter is a string with a Where Condition, eg;
Now, I want to be able to take the contents of a combo box on the form, that specifies a field name in the report, and use that to determine the sort order of the report. That is I want to replicate the SQL (note that the SELECT statement isn't a simple SELECT * FROM..., but you get the idea);
Is this possible? The DoCmd.OpenReport method does not seem to support this. I had also considered setting the OrderBy property of the report to the field, but this can only be done after I open the report, meaning I can't send the ordered report direct to the printer (eg using acViewNormal).
Thanks in advance.
Code:
DoCmd.OpenReport strReport, acViewPreview, , strFilter
where strFilter is a string with a Where Condition, eg;
Code:
"[Meeting] = 3"
Now, I want to be able to take the contents of a combo box on the form, that specifies a field name in the report, and use that to determine the sort order of the report. That is I want to replicate the SQL (note that the SELECT statement isn't a simple SELECT * FROM..., but you get the idea);
Code:
SELECT * FROM tblTableName WHERE [Meeting] = 3 ORDER BY [FieldName];
Is this possible? The DoCmd.OpenReport method does not seem to support this. I had also considered setting the OrderBy property of the report to the field, but this can only be done after I open the report, meaning I can't send the ordered report direct to the printer (eg using acViewNormal).
Code:
DoCmd.OpenReport strReport, acViewPreview, , strFilter
Reports!strReport.Report.OrderBy = [FieldName]
Reports!strReport.Report.OrderByOn = True
Thanks in advance.