Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open a criteria based Report from a Form?

Status
Not open for further replies.

bjayhome

Technical User
Dec 13, 2001
17
0
0
US
Hi All,

I want to use a Form to get parameter values (criteria’s) from the user for a Query, and then use these values to open a Report, which has its ‘recordsource’ set to the earlier mentioned query.
Could anyone help me? I want to do it through VB code. Thank you in advance for your help. :)

Bjay
 
Not sure if you're interested in doing this way...without the use of VB, but it works just as well. The way I do it is this:

1) Set up an unbound criteria form with your input values as text boxes or combo, etc., these are unbound controls.

2) Create a macro group with 4 macros, one to open the form, another to close the form, one for the OK command button on your form, and the last for a CANCEL button on your form.

3) In the RECORDSOURCE property of your underlying query or report, include the unbound control names from the form in the CRITERIA.

For example, for a form called Orders, you would
use the following to refer to control for Begin Date
and End Date:

Between [Forms]![Orders]![Begin Date] And [Forms]![Orders]![End Date]

4) In the properties for you report, set OnOpen property to the name of macro that opens your unbound form, and OnClose the name of the macro the closes the unbound form.

I don't know much about VB, but this should work too, maybe not as fast.

TN
 
I was hoping to do it through code, but I will try this way. Thanks a lot!!

Bjay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top