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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values to a report

Status
Not open for further replies.

tpowers

Technical User
Nov 2, 2002
153
US
I have a form that only has unbound controls. On this form I have a button that will allow users to print are report that will display the data that is on the screen. The problem that I am having is that since the form is not bound to any table or query I do not know how to do this. Is there a way to pass the values from the form right to the report.

If so how?

Thank you in advance,

TPowers
 
tpowers: Sure, in the Control source of each textbox on the Report just put in the reference to the corresponding values on the Form, e.g.,

=Forms![frmMyform]![txtMytextbox]

...so, when you hit the print button, put on button's OnClick Event:

Visible = False
DoCmd.OpenReport "rptMyReport"

..and then on the OnClose Event of the Report put:

Forms![frmMyform].Visible = True

...that way the Report can look to the Form for the values. It should be that simple.
 
Hello Isadore, thank you for your help it worked great, but there was only one problem when I went to print it, all my fields had no data, instead it showed #name? in all the fields. Do you know why?

Thanks for your help in advance,

TPowers
 
Sound like you bound the Report to a query. Since you're Form has unbound form, your Report should not be bound. Or, if only a few of the field are unbound, and others are bound, follow the same in the Form and Report.

The #Name usually comes up when you "bind" a textbox to a control, but that field is not available in the underlying query. If that's not it, fire a post back and we'll investigate a bit further.
 
I've set up reports bounded to tables or queries and still can bind the fields to form text boxes.

Just checking, the form is not being closed before you print out the report?
 
dakota is correct. You can have "partial" binding, and some textboxes can remain unbound, those are the ones you want to "look" to the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top