Filter Report by Subform Records

D

Doctor

I have a subform that shows churches that participated in an activity.

I have a report that is designed to print mailing labels for all churches in
the database.

I would like to place a button on the subform that will open the report but
include only the records for churches in the subform. This subform is not
filtered. Both the subform and the report include the field ChurchID. A2K3

Help.

******
This code only prints the current record selected in subform.
stWhere = "[ChurchID]=" & Me![ChurchID]

stDocName = "rptCharterChurchLabels 5160"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Thanks in advance.
 
D

Duane Hookom

Why not put the button in the main form to filter the label report by the
activity rather than attempting this with the subform records?
 
D

Doctor

Well, of course, I could set up a new query for a new report. But we often
print labels for churches based on a variety of things. I was hoping there
was a way to accomplish this so that I would only have to have one report.

Is it possible to build a record set, then open the report only showing
records where the ChurchID is present in the recordset?

Duane Hookom said:
Why not put the button in the main form to filter the label report by the
activity rather than attempting this with the subform records?

--
Duane Hookom
Microsoft Access MVP


Doctor said:
I have a subform that shows churches that participated in an activity.

I have a report that is designed to print mailing labels for all churches in
the database.

I would like to place a button on the subform that will open the report but
include only the records for churches in the subform. This subform is not
filtered. Both the subform and the report include the field ChurchID. A2K3

Help.

******
This code only prints the current record selected in subform.
stWhere = "[ChurchID]=" & Me![ChurchID]

stDocName = "rptCharterChurchLabels 5160"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Thanks in advance.
 
D

Duane Hookom

I wouldn't create a new report. You can build a SQL string and set the
report's record source in the On Open event of the report. You could also
build a SQL string and use it to set the SQL property of a saved query that
is the record source of the report.

--
Duane Hookom
Microsoft Access MVP


Doctor said:
Well, of course, I could set up a new query for a new report. But we often
print labels for churches based on a variety of things. I was hoping there
was a way to accomplish this so that I would only have to have one report.

Is it possible to build a record set, then open the report only showing
records where the ChurchID is present in the recordset?

Duane Hookom said:
Why not put the button in the main form to filter the label report by the
activity rather than attempting this with the subform records?

--
Duane Hookom
Microsoft Access MVP


Doctor said:
I have a subform that shows churches that participated in an activity.

I have a report that is designed to print mailing labels for all churches in
the database.

I would like to place a button on the subform that will open the report but
include only the records for churches in the subform. This subform is not
filtered. Both the subform and the report include the field ChurchID. A2K3

Help.

******
This code only prints the current record selected in subform.
stWhere = "[ChurchID]=" & Me![ChurchID]

stDocName = "rptCharterChurchLabels 5160"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Thanks in advance.
 
D

Doctor

Thanks Duane! You've pointed me in the right direction.

Duane Hookom said:
I wouldn't create a new report. You can build a SQL string and set the
report's record source in the On Open event of the report. You could also
build a SQL string and use it to set the SQL property of a saved query that
is the record source of the report.

--
Duane Hookom
Microsoft Access MVP


Doctor said:
Well, of course, I could set up a new query for a new report. But we often
print labels for churches based on a variety of things. I was hoping there
was a way to accomplish this so that I would only have to have one report.

Is it possible to build a record set, then open the report only showing
records where the ChurchID is present in the recordset?

Duane Hookom said:
Why not put the button in the main form to filter the label report by the
activity rather than attempting this with the subform records?

--
Duane Hookom
Microsoft Access MVP


:

I have a subform that shows churches that participated in an activity.

I have a report that is designed to print mailing labels for all churches in
the database.

I would like to place a button on the subform that will open the report but
include only the records for churches in the subform. This subform is not
filtered. Both the subform and the report include the field ChurchID. A2K3

Help.

******
This code only prints the current record selected in subform.
stWhere = "[ChurchID]=" & Me![ChurchID]

stDocName = "rptCharterChurchLabels 5160"
DoCmd.OpenReport stDocName, acPreview, , stWhere

Thanks in advance.
 

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