Print Report based on Value on Form

  • Thread starter Thread starter Pam
  • Start date Start date
P

Pam

I have a Form with a subform and am wanting to print a
report and use the Current datarow's value (Invoice
Number) and use that for the critiera in my report to
print out.

I went to a Macro and did an OpenReport. then in the
where I put reports.rptInvoice.INVNBR =
forms.frmInvoice.INVMBR. But I get only the report with
no data (ERROR). In my forms view, there are more than
one record open, I am just wanting to print the current
record's INVOICE Number in that report.

What am I doing wrong?
 
The subform is not open in its own right, so it will not be found in the
Forms collection.

You need to refer to it through the main form:
Forms![MainFormName]![SubformControlName].Form![INVNBR]

If the ".Form" bit doesn't make sense, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html
 
I am wanting to refer to a control on the main form. But
it won't work. There is a subform as well, but the
control I am wanting to use in the condition clause comes
form the main form.
-----Original Message-----
The subform is not open in its own right, so it will not be found in the
Forms collection.

You need to refer to it through the main form:
Forms![MainFormName]![SubformControlName].Form! [INVNBR]

If the ".Form" bit doesn't make sense, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have a Form with a subform and am wanting to print a
report and use the Current datarow's value (Invoice
Number) and use that for the critiera in my report to
print out.

I went to a Macro and did an OpenReport. then in the
where I put reports.rptInvoice.INVNBR =
forms.frmInvoice.INVMBR. But I get only the report with
no data (ERROR). In my forms view, there are more than
one record open, I am just wanting to print the current
record's INVOICE Number in that report.

What am I doing wrong?


.
I
 
Don't include the name of the name of the report in the WhereCondition.

Also, check whether you need INVNBR or INVMBR. Try:
[INVNBR] = [Forms]![frmInvoice]![INVNBR]
 
Back
Top