View Full Version : getting a parameter from Form to Report


sjl
10-18-2007, 09:21 AM
Folks,

I am trying to grab a calculated variable from a subform (which is part of a data entry Form) to place it onto a Report.

I read a past posting to the Forum that said to "Set the control source of the text box on your report to =Forms!NameofForm!Nameoftxtbox, substituting your actual form name and name of text box that holds the date"
(from http://www.access-programmers.co.uk/forums/showthread.php?t=131709&highlight=grab+data+form+Report)


I have placed this in the control of a text box of my Report. It gives me the #Name? statement.

=[Forms]![fsub_NIEHS]![txtCOIdue]

**do I actually use the word "Forms" for the first parameter in the above statement?

the name of my subform (as seen in the Forms window, outside the subform), is "fsub_NIEHS"

**do I use a bound or an unbound text box?

thanks in advance,
sjl

pbaldy
10-18-2007, 09:25 AM
If it's a subform, the syntax is different. Good reference here:

http://www.mvps.org/access/forms/frm0031.htm

sjl
10-18-2007, 09:45 AM
Thanks,

I have that reference printed out, and tried to follow it but don't know which
syntax to use when working in a report. I assume it is the one under
these categories:

Not in these forms
To refer to a control
On Sub 1

Forms!Mainform!Subform1.Form!ControlName

but....what do I put in the "Form" place above?

Thanks again,
sjl

pbaldy
10-18-2007, 09:55 AM
Nothing; it stays as is (as does "Forms").

sjl
10-18-2007, 10:34 AM
Thanks for your response.

I still can't get it to run without the #Name? error. This is what I have:

=[Forms]![frmDataEntry_9_06]![fsub_NIEHS].[Form]![txtCOIdue]

frmDataEntry_9_06 is the FORM
fsub_NIEHS is the Subform
txtCOIdue is a calculated control--it's calculated on "fsub_NIEHS"


Not sure if I'm grabbing the names for the Form and the Subform from the right place....I grabbed them from the listing of Forms in the database window.

Maybe the calculated control is causing the problem...."txtCOIdue" is its name in the subform where it is created.

thanks,
sjl

pbaldy
10-18-2007, 12:00 PM
It's a subtle difference, but for the subform you want the name of the subform control on the main form, not the name of the subform itself (though it could be the same thing).

sjl
10-18-2007, 12:45 PM
thanks for your input,

I replaced the subform name that I had, with the name of the subform control (per your advice).

=[Forms]![frmDataEntry_9_06]![fsubNIEHS].[Form]![txtCOIdue]


It still is not displaying the value but it did change the error...now it is: Error# (not Name?)

the Subform sits on a tab ("tabNIEHS"). Do I need to include the tab name?

thanks,
sjl

pbaldy
10-18-2007, 01:00 PM
No, the tab name is not needed (or even possible). The form is open when the report runs, right? Can you post a sample db?

sjl
10-18-2007, 01:21 PM
Nope--I did not have my form open (didn't know this was required..?)
Thanks! It now works!:D

gracias!
sjl