filter report by value in subform (1 Viewer)

lbs

Registered User.
Local time
Today, 11:52
Joined
Dec 22, 2019
Messages
109
Hello experts

I have a form which has a subform. At the bottom of the main form I have a button for opening a report. I want that report to be filtered according to the value showing in one filed of the subform. Is it possible to achieve? How to write a where condition in the Open report command?

Many thanks
 

Ranman256

Well-known member
Local time
Today, 06:52
Joined
Apr 9, 2015
Messages
4,337
the query for the report would use the selected record as the criteria.
open the form (w the subform)
make a query, then use the BUILDER to insert the criteria.
select active forms
your form, then the subform,
then the field (txtbox).
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:52
Joined
Oct 29, 2018
Messages
21,467
Hi. Also, if you use the OpenReport method, there is a WhereCondition argument. For example:
Code:
DoCmd.OpenReport "ReportName", acViewPreview, , "ReportFieldName='" & Me.SubformContainerName.Form!FieldControlName & "'"
That's assuming it's a Text field.
 

lbs

Registered User.
Local time
Today, 11:52
Joined
Dec 22, 2019
Messages
109
theDBguy, Ranman256,
Many thanks

It works now
 

Users who are viewing this thread

Top Bottom