Programmatically control Report Grouping & Sorting via Form

J

Jen S

I have a form with combo boxes & textboxes as input selections to generate a
report. At the same time, I would like to give User the flexibility to do
sorting and grouping on the report by opening a mini form that will use
option buttons to indicate which field is being selected by User to do
sorting and grouping.
Based on User selection, the report will be generated accordingly.

How do I pass the form parameters to the report before it generates the data?

TKQ IA....
 
M

Marshall Barton

Jen said:
I have a form with combo boxes & textboxes as input selections to generate a
report. At the same time, I would like to give User the flexibility to do
sorting and grouping on the report by opening a mini form that will use
option buttons to indicate which field is being selected by User to do
sorting and grouping.
Based on User selection, the report will be generated accordingly.

How do I pass the form parameters to the report before it generates the data?


Changing (not adding or removing) a report's sort/group
needs to be done in the report's Open event procedure. Then
general idea is to use code along these lines:

Me.GroupLevel(N).ControlSource = "field name or expression"

If the form with the options is remains open while the
report runs, then your code can get the needed info from the
form:

If Forms!theform.somecontrol = something Then
Me.GroupLevel(N).ControlSource = "field1"
Else
Me.GroupLevel(N).ControlSource = "field2"
End If

If the form closes itself when it opens the report, then it
can pass the info to the report using the OpenReport
method's OpenArgs argument:

If Me.OpenArgs = something Then
Me.GroupLevel(N).ControlSource = "field1"
Else
Me.GroupLevel(N).ControlSource = "field2"
End If

The N in the above is the 0 based number of the item in the
sort/group list.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top