Remove string from string

B

Brian

My users would like to be able to print a report based on criteria they
selected by right-clicking various fields on a continuous form. I have
already written the report, but I need to know how to pass the Filter and
OrderBy parameters to the report.

In VBA I wrote:
reports(reportname).Filter = formname.filter
reports(reportname).OrderBy = formname.orderby

This works except that the string that passes to the report includes the
form name, thereby rendering the string unusable since the report has a
different name than the form.

Therefore, I think my question really is...how do I parse out the form name
from the strings I am passing to the report.

Or my other question would be, how else can I do this?
 
K

Klatuu

First, that is not going to work.
Using the Form's filter property for the report's filter assumes the same
field(s) exist in the reports record source that are in the form's
recordsource.
The way to set the filtering is to sue the Where argument of the OpenReport
method:
Docmd.OpenReport "ReportName", , , Me.Filter

The larger problem will be the Order By. Reports disregard the order of the
recordsource. By that I mean regardless of what the Order By is in the
query, it may or may not present in that order in the report You can set the
the OrderBy property of the report in the report's Open event. You also need
to set the OrderbyOn property as well.
Private Sub Report_Open()

With Me
.OrderBy = Forms!FormName.OrderBy
.OrderByOn = True
End With

End Sub
 

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