lost in forms

  • Thread starter Thread starter jan
  • Start date Start date
J

jan

I have created a form/subform and duplicated a
report/subreport based on that form. The main goal was to
be able to provide the user with the option of printing
the information contained in the form, so I added a print
button that calls the report/subreport. However, when the
user clicks on the print button, it prompts them for the
criteria, which was already specified at the form level.
How can I eliminate the step of having the user key in the
information again?

thanks,

Jan
 
Hi Jan,

What exactly do you mean by "which was already specified at the form level"
(referring to the criteria)? If you have a control which contains the value
you are using as a filter you can either a)Use the WhereCondition parameter
of Docmd.OpenReport. This is just like using the same parameter of
Docmd.OpenForm.

DoCmd.OpenReport "rptSalesOrder",,, "Orderid=" & Me.OrderID

Another way is to refer directly to a control in the where clause of the
saved query that is the Controlsource for the report. The SQL would look
something like this:

Select * from tblOrders
where Orderid=forms!frmOrders!Orderid;


This of course requires that the frmOrders is open (else you get the prompt)
and it also causes the query to be dependant on the form.

There are other more complex ways to do this but these are the easiest and
most common. Post more info about your situation if you still need some help
with this.
 
Back
Top