Choose printer+parameters programatically

E

Estêvão Raminhos

Hi all,

Is there a way to choose the destination printer + parameters
programatically when we want to print a report? If so, can those parameters
be in such a detail as to allow choosing the paper size and margins (left,
right, top, bottom), for example?

Let me explain the need of such a solution (and the problem we are getting):
in a network environment, some reports (an invoice or a voucher, for
example) need to be printed to dot matrix printers (Epson LQ-680 and Epson
LQ-570, specifically), where there is pre-printed form paper (so things need
to be printed within very specific zones). On the program we have specific
buttons to print the reports and they are able to choose the printer before
previewing the report. That works fine. Before printing, if the user defines
the correct margins and paper size, that works all right too... and the
chosen parameters are preserved for future printouts. The problem is that
when we convert the MDB file into an MDE file, the MDE file only prints well
from the workstation where we previously ran the MDB file. On other
workstation, for some strange reason, the printing button calls the correct
printer but not the correct parameters (paper size, margins, etc.) and the
preview is incorrect. If we run the MDB file on the second workstation and
setup the parameters, then this workstation starts working well with the
printer but the first workstation (which was already setup) looses the
correct parameters and starts pinting badly. This means that we can only
have only workstation correctly setup for each report, i.e., only one
workstation can print invoices (correctly) while only another workstation
can print vouchers (correctly). We would obviously like to have ALL
workstations printing both reports correctly in an automatic manner but we
are not being able to. We are using ACCESS 2002 and Windows XP Pro SP2.

Any solution?

TIA

Estêvão Raminhos
(e-mail address removed)
 
S

SA

Estêvão:

You can not change report parameters for reports in a MDE database at run
time. There is absolutely no way to do it, Access doesn't allow you to set
up those properties in an MDE. You can do that via code in an MDB database,
so rather than using an mde, you've got to stay with an mdb if you need code
to adjust the report.

One thing you may want to try doing is to define a custom paper size for the
form within windows (open the printers folder, then from File -> Server
properties, choose the forms tab and set up the paper size you are
targeting, replicate on all machines and then set the report to that paper
size.) Secondly, don't let the user print from a previewed report. This
is because if you open a report in preview and then switch printers, the
report will always take on the "default" settings for the newly selected
printer, screwing up your report's settings. The solution is to create
custom tool bars and menus that don't have a print option and only print
using a command button on your form WHILE THE REPORT IS CLOSED. When a
report is sent to a printer using code (rather than from the interface) it
will retain its paper settings, provided that the target printer supports
those settings. Allow it to be previewed and then the printer changed and
you will run into problems.

HTH
 

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