printing report from subform selection

G

Grip

I have a db with the table MembershipTypes, People, and Members (join
between MembershipTypes and People).

I have a form with a subform that lists Membership types in a
datasheet view. I have another subform that lists the Members of the
selected Membership Type. I would like to print a report of all the
People who are Members of a selected MembershipType, but I'm a little
lost on where to begin.

I started by building the Report on a Query but don't know how to pass
the MemberhsipTypeID to the query.

Any help would be appreciated.

Thanks,
G
 
K

Klatuu

Rather than pass it to the query, use the Where argument of the OpenReport
method to filter the report on membership type.
When you reference a control name on a datasheet subform, it returns the
value of the current row. So, assuming the command button is on the main
form to print the report filtering on the member type selected in the subform:

Docmd.OpenReport "ReportName", , , "[MemberType] = """ &
Me.SuFormControlName.Form.txtMemberType & """"

SuFormControlName is the name of the subform control on the main form, not
the name of the form being used as the subform.
[MemberType] would be the name of the field in the report's recordset you
want to filter on. The example above assumes it is a text data type field.
txtMemberType would be the name of the control on the subform you want to
use to filter the report.
 

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