From: Ken Warthen on
I have a split form in an Access 2007 database where the data grid shows the
records from a query. The user can filter any combination of fields from the
the drop down headers. I have a command button above the data grid that
opens a report with the same query as its record source. I'm trying to
figure out how to pass the filtered data to the report so it will show only
those records that the user is seeing in the data grid of the split form.
Any help with this issue will be greatly appreciated.

Ken
From: Allen Browne on
You may be able to pass the Filter of your form as the WhereCondition of the
report.

The code for your button would look like this:
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.FilterOn Then strWhere = Me.Filter
DoCmd.OpenReport "Report1", acViewPreview, , strWhere

It may be a bit more complex if you have combo boxes where the bound column
is not the display column, or multi-valued fields.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Ken Warthen" <KenWarthen(a)discussions.microsoft.com> wrote in message
news:ADB21FDF-D7E0-4667-AC8B-72CF248A2019(a)microsoft.com...
> I have a split form in an Access 2007 database where the data grid shows
> the
> records from a query. The user can filter any combination of fields from
> the
> the drop down headers. I have a command button above the data grid that
> opens a report with the same query as its record source. I'm trying to
> figure out how to pass the filtered data to the report so it will show
> only
> those records that the user is seeing in the data grid of the split form.
> Any help with this issue will be greatly appreciated.
>
> Ken

From: Ken Warthen on
Allen,

Thanks so much for the help, your suggestion seems to work perfectly. I
have a multi-valued field displayed on the split form and your code seems to
be able to pass any filtering of that field to the report without issue.

Thanks again,

Ken

"Allen Browne" wrote:

> You may be able to pass the Filter of your form as the WhereCondition of the
> report.
>
> The code for your button would look like this:
> Dim strWhere As String
> If Me.Dirty Then Me.Dirty = False
> If Me.FilterOn Then strWhere = Me.Filter
> DoCmd.OpenReport "Report1", acViewPreview, , strWhere
>
> It may be a bit more complex if you have combo boxes where the bound column
> is not the display column, or multi-valued fields.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
>
> "Ken Warthen" <KenWarthen(a)discussions.microsoft.com> wrote in message
> news:ADB21FDF-D7E0-4667-AC8B-72CF248A2019(a)microsoft.com...
> > I have a split form in an Access 2007 database where the data grid shows
> > the
> > records from a query. The user can filter any combination of fields from
> > the
> > the drop down headers. I have a command button above the data grid that
> > opens a report with the same query as its record source. I'm trying to
> > figure out how to pass the filtered data to the report so it will show
> > only
> > those records that the user is seeing in the data grid of the split form.
> > Any help with this issue will be greatly appreciated.
> >
> > Ken
>
> .
>