Printing Invoices

2565

New member
Local time
Today, 09:38
Joined
Feb 20, 2002
Messages
5
I want to print a report using the information displayed by the form currently on my screen. In this case an invoice(The form is based upon a query).
How do I do this without printing invoices for all the information held within the query.
 
You could do this a couple of ways

1 create a query for the report and, in the criteria for the unique id number for the record on the form, build an expression back to the form: Forms![formname]![UniqueIDfield]. Obviously you will need to rename the form name and field name with the correct names!

On the command button OnClick event:

DoCmd.OpenReport "YourReportName",acPreview

This way has the query filtering the report to show the record related to the current record on the form.

2

On the OnClick event of the command button do:

DoCmd.OpenReport "YourReportName",acPreview
, , "[UniqueID] = " & Me![UniqueJob]

This tells the report to open in design view and show the records that matches the current record on your form.

Both do the same thing, only differently. I prefer version 2 because I can then open one report from various places (switchboard, dialog box, form) where if I used version 1 I would need three reports with three different queries
 
I am using this method myself to print a report, but I now need to print 2 copies of the report. How do I modify the code to do this?
 
I tried the second method as descibed, and I received a message saying it couldn't find the Docmd macro. Am I missing something?
 
DoCmd.<method> is the VBA way of doing something similar to calling afunction in a Macro. I believe you can just call OpenReport from a Macro, correct?

However, since Macros are being phased out and may not be supported in the future, it would be wise to start getting familiar with them now. It's actually not nearly as scary as it sounds, because the VBA window is very good at prompting you to complete things with likely values/functions, and provides a 'tip' box to let you know what part of the function you're working in.
To see an example of this, open a blank module and start to type, slowly:
DoCmd.OpenReport , , , ,

Hope that helps,
David R
 

Users who are viewing this thread

Back
Top Bottom