setting up the printer in a mde

S

Squik27

I have an mdb application, it's gotta a backend. I convert the mdb to mde.
Here's the problem; some of the reports in the mdb are to print to a
different printer -not the default printer- when i convert to mde and take
the application to other network -I can set up the backend for the mde for
the other network, this is not a problem- the reports that do not use the
default printer won't print and i can't open the set up page for a report in
a mde.

How can i set up the printer in the mde?

Thanks
 
A

Albert D. Kallal

Squik27 said:
I have an mdb application, it's gotta a backend. I convert the mdb to mde.
Here's the problem; some of the reports in the mdb are to print to a
different printer -not the default printer- when i convert to mde and take
the application to other network -I can set up the backend for the mde for
the other network, this is not a problem- the reports that do not use the
default printer won't print and i can't open the set up page for a report
in
a mde.

How can i set up the printer in the mde?

Thanks

You don't mention what version\ of ms-access.

In access 2002 and later, there is a built in printer object, and it lets
you switch the printer with ease.

You can use:

Set Application.Printer = Application.Printers("HP LaserJet Series II")


So, here what I do:

All reports are set to default printer. I mean, if you choose a particular
printer, and the user installs even a NEW version of the SAME printer, then
often the printer driver changes. So, this is near impossible to manage.

So, I use code:

So, to save/switch, you can use:

dim strDefaultPrinter as string

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("HP LaserJet Series II")

do whatever, print reports..

Switchback.

Set Application.Printer = Application.Printers(strDefaultPrinter)
 
S

Squik27

Ok. it isn't working. This is my code. I get invalid procedure call or
argument. the printer name is the share name. I'm using access 2003

Option Compare Database

Dim var As String

Private Sub Form_Open(Cancel As Integer)
var = "StarTSP7"
Set Application.Printer = Application.Printers(var)
MsgBox Me.Printer.DeviceName
End Sub

Private Sub Form_Close()
MsgBox var
End Sub
 
A

Albert D. Kallal

I would first try the following code in a standard code module.

Sub myTest()

Dim pDef As Printer

For Each pDef In Printers
Debug.Print pDef.DeviceName
Next


End Sub

The above will give you an idea of the actual printer name.

Also, I believe you have to switch the printer BEFORE you launch the report.
The report uses the existing printer to render the layout. The report will
already have started printing and doing layout BEFORE the on-open is
completed. You could test this if you preview the report first. If you let
the report render (preview), then again you likey can swtich printer.
However, I don't think you can do it "during" on-open.

Also, you are using me.Printer in your example. "me" refers to the report
and you want to use Application.Printer or leave out application. (so, even
if you fix this, me.Printer is wrong)
Set Application.Printer = Application.Printers(var)
MsgBox Me.Printer.DeviceName

Does the above code fail on the 1st line, or the 2nd one? (however, as
mentioned, even if you fix this, the problem is you must let the report
finish rendering for the given printer setting, so on-open likely not
workable).

I would suggest for ease of use, you build some type of interface for those
reports.

A few screen shots + ideas I use for reports is here:

http://www.members.shaw.ca/AlbertKallal/ridesrpt/ridesrpt.html

So, my spider sense tells me you have to switch this before you launch the
report.
 

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