Print Report for current Invoice Number

M

Maureen227

I have a form with invoice data and would like to print a report with a
button on the form. My problem is I don't know how to tell the report
to print for the current record's invoice number.

Any help would be great. Thanks ahead
Maureen
 
F

fredg

I have a form with invoice data and would like to print a report with a
button on the form. My problem is I don't know how to tell the report
to print for the current record's invoice number.

Any help would be great. Thanks ahead
Maureen

Assuming the Invoice number is a unique prime key field and is a
Number datatype, not text:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = " &
Me![InvoiceNumber]

If [InvoiceNumber] is text, then use:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = '"
& Me![InvoiceNumber] & "'"
 
M

Maureen227

fredg said:
I have a form with invoice data and would like to print a report with a
button on the form. My problem is I don't know how to tell the report
to print for the current record's invoice number.

Any help would be great. Thanks ahead
Maureen

Assuming the Invoice number is a unique prime key field and is a
Number datatype, not text:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = " &
Me![InvoiceNumber]

If [InvoiceNumber] is text, then use:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = '"
& Me![InvoiceNumber] & "'"

Fred
This work great. Thanks a Terabyte.
My in voice number was a text box and i was using the code for a number
field.
Maureen
 
G

Guest

this works great, however - how can we capture any new data on this form -
not showing up when the button is pushed.
Thanks,


fredg said:
I have a form with invoice data and would like to print a report with a
button on the form. My problem is I don't know how to tell the report
to print for the current record's invoice number.

Any help would be great. Thanks ahead
Maureen

Assuming the Invoice number is a unique prime key field and is a
Number datatype, not text:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = " &
Me![InvoiceNumber]

If [InvoiceNumber] is text, then use:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = '"
& Me![InvoiceNumber] & "'"
 
F

fredg

this works great, however - how can we capture any new data on this form -
not showing up when the button is pushed.
Thanks,

fredg said:
I have a form with invoice data and would like to print a report with a
button on the form. My problem is I don't know how to tell the report
to print for the current record's invoice number.

Any help would be great. Thanks ahead
Maureen

Assuming the Invoice number is a unique prime key field and is a
Number datatype, not text:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = " &
Me![InvoiceNumber]

If [InvoiceNumber] is text, then use:

DoCmd.OpenReport "ReportName", acViewPreview, , "[InvoiceNumber] = '"
& Me![InvoiceNumber] & "'"

Newly entered data in a form is not saved until you close the form,
move to another record, or explicitly tell it to save the record.

Add one line of code to the command button click event to first save
the record:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Reportname", etc......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top