Create a report based on a filtered form using a command button

  • Thread starter cscotty via AccessMonster.com
  • Start date
C

cscotty via AccessMonster.com

Hello everyone.

I am trying to create a report based on a filtered form. I use a query to
filter data into a form that I have. Now, I created a command button and
placed it on my filtered form. When I click on the button, I would like it
to create a report with the data retrieved from the form. It was suggested
that I just link the reports source to the query, but that would not work
because my users would need to see the form to edit it, THEN print the report.


Any help is appreciated. If I need to provide you with more info, please let
me know.

Thanks,
Scott
 
D

Danny Lesandrini

Scott:

There are many ways to implement filtering of a report from a form.

The simplest is just to add a WHERE clause to the call to open the report

' text value in [Category] control delimited with single quotes
strWHERE = "[Category]='" & Me!cboCategory & "'"

DoCmd.OpenReport "rptYourReport",acViewPreview, ,strWhere


Of course, you can get much more complicated than that. I've got a
pretty comprehensive example on my site.

http://www.amazecreations.com/datafast/daaug/ReportFilter.zip
 
C

cscotty via AccessMonster.com

Hey Danny,

Thanks for your help. Your example is extensive indeed. Can you please
explain what is meant in your code by strWHERE = "[Category]='" & Me!
cboCategory & "'".

Thanks,
Scott

Danny said:
Scott:

There are many ways to implement filtering of a report from a form.

The simplest is just to add a WHERE clause to the call to open the report

' text value in [Category] control delimited with single quotes
strWHERE = "[Category]='" & Me!cboCategory & "'"

DoCmd.OpenReport "rptYourReport",acViewPreview, ,strWhere

Of course, you can get much more complicated than that. I've got a
pretty comprehensive example on my site.

http://www.amazecreations.com/datafast/daaug/ReportFilter.zip
Hello everyone.
[quoted text clipped - 10 lines]
Thanks,
Scott
 
D

Douglas J. Steele

Danny's assuming that there's a combo box named cboCategory on your form
from which you're going to select an entry that you want used to limit
what's on the report when it opens.

He's further assuming that the RecordSource of the report you're trying to
open contains a field named Category.

What he's doing is creating a Filter so that all that will be displayed are
the records for which the Category field equals whatever was selected in the
combo box.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


cscotty via AccessMonster.com said:
Hey Danny,

Thanks for your help. Your example is extensive indeed. Can you please
explain what is meant in your code by strWHERE = "[Category]='" & Me!
cboCategory & "'".

Thanks,
Scott

Danny said:
Scott:

There are many ways to implement filtering of a report from a form.

The simplest is just to add a WHERE clause to the call to open the report

' text value in [Category] control delimited with single quotes
strWHERE = "[Category]='" & Me!cboCategory & "'"

DoCmd.OpenReport "rptYourReport",acViewPreview, ,strWhere

Of course, you can get much more complicated than that. I've got a
pretty comprehensive example on my site.

http://www.amazecreations.com/datafast/daaug/ReportFilter.zip
Hello everyone.
[quoted text clipped - 10 lines]
Thanks,
Scott
 
C

cscotty via AccessMonster.com

Thanks Douglas!

I will try it and report back.

Thanks,
Scott
Danny's assuming that there's a combo box named cboCategory on your form
from which you're going to select an entry that you want used to limit
what's on the report when it opens.

He's further assuming that the RecordSource of the report you're trying to
open contains a field named Category.

What he's doing is creating a Filter so that all that will be displayed are
the records for which the Category field equals whatever was selected in the
combo box.
Hey Danny,
[quoted text clipped - 26 lines]
 

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