Specifying a Printer

G

Guest

Hi,

My small database application is stored on a network drive. Our office has
four floors with several printers on each floor. We select our default
printer from a list of available printers. We can change our default
printer, or we can just change printers for a single job via the Print screen.

I'd like to code my Print command button so that it always sends the report
to the same printer. How can I do this? Do I need to contact our IT people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
K

Ken Snell [MVP]

Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that can
be used to do what you seek. You'll need to know the printer device name for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub
 
G

Guest

Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the device name?
E.g.,

Set Application.Printer = L200604

Thanks!




Ken Snell said:
Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that can
be used to do what you seek. You'll need to know the printer device name for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Rosemary said:
Hi,

My small database application is stored on a network drive. Our office
has
four floors with several printers on each floor. We select our default
printer from a list of available printers. We can change our default
printer, or we can just change printers for a single job via the Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
K

Ken Snell [MVP]

No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see in the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer back to
the default printer.
--

Ken Snell
<MS ACCESS MVP>



Rosemary said:
Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




Ken Snell said:
Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that
can
be used to do what you seek. You'll need to know the printer device name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Rosemary said:
Hi,

My small database application is stored on a network drive. Our office
has
four floors with several printers on each floor. We select our default
printer from a list of available printers. We can change our default
printer, or we can just change printers for a single job via the Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
G

Guest

I see. Thanks. My line of code looks like this:

Application.Printers("\\geoprint\K030223")

I've also tried it like this:

Application.Printers("K030223")

It's not working yet -- I think I have to ask my IT dept. how to correctly
write the path to the printer which is named K030223. Is that correct?

Regards,
Rosemary


Ken Snell said:
No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see in the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer back to
the default printer.
--

Ken Snell
<MS ACCESS MVP>



Rosemary said:
Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




Ken Snell said:
Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that
can
be used to do what you seek. You'll need to know the printer device name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Hi,

My small database application is stored on a network drive. Our office
has
four floors with several printers on each floor. We select our default
printer from a list of available printers. We can change our default
printer, or we can just change printers for a single job via the Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
K

Ken Snell [MVP]

What I suggest you try first is to open the VBE and go to the Immediate
Window. In the window, type this expression and press Enter:

?Application.Printers(0).DeviceName

You'll get a name for the first printer in the collection. Then change the 0
to a 1, and press Enter. You'll get the name of the second printer. Continue
until you find the device name that you want, and then use that name in the
expression we posted earlier.

If you get an error when you put in a number that goes beyond the number of
printers, then the printer you want either is not mapped/connected to the
PC, or it has an unexpected name that you didn't recognize. In this case,
you'll need to talk with IT to identify the name that you need to use.
--

Ken Snell
<MS ACCESS MVP>


Rosemary said:
I see. Thanks. My line of code looks like this:

Application.Printers("\\geoprint\K030223")

I've also tried it like this:

Application.Printers("K030223")

It's not working yet -- I think I have to ask my IT dept. how to correctly
write the path to the printer which is named K030223. Is that correct?

Regards,
Rosemary


Ken Snell said:
No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see in
the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer back
to
the default printer.
--

Ken Snell
<MS ACCESS MVP>



Rosemary said:
Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




:

Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that
can
be used to do what you seek. You'll need to know the printer device
name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Hi,

My small database application is stored on a network drive. Our
office
has
four floors with several printers on each floor. We select our
default
printer from a list of available printers. We can change our
default
printer, or we can just change printers for a single job via the
Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our
IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
G

Guest

Hi Ken,

That worked great -- I was able to find the printer I was looking for and at
least know I was identifying it correctly. This was helpful for me to learn
about.

The procedure is still not functioning, though, so -- as you mentioned -- I
am contacting my IT dept. to ask them how to get my procedure to "see" this
printer.

Thanks!


Ken Snell said:
What I suggest you try first is to open the VBE and go to the Immediate
Window. In the window, type this expression and press Enter:

?Application.Printers(0).DeviceName

You'll get a name for the first printer in the collection. Then change the 0
to a 1, and press Enter. You'll get the name of the second printer. Continue
until you find the device name that you want, and then use that name in the
expression we posted earlier.

If you get an error when you put in a number that goes beyond the number of
printers, then the printer you want either is not mapped/connected to the
PC, or it has an unexpected name that you didn't recognize. In this case,
you'll need to talk with IT to identify the name that you need to use.
--

Ken Snell
<MS ACCESS MVP>


Rosemary said:
I see. Thanks. My line of code looks like this:

Application.Printers("\\geoprint\K030223")

I've also tried it like this:

Application.Printers("K030223")

It's not working yet -- I think I have to ask my IT dept. how to correctly
write the path to the printer which is named K030223. Is that correct?

Regards,
Rosemary


Ken Snell said:
No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see in
the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer back
to
the default printer.
--

Ken Snell
<MS ACCESS MVP>



Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




:

Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that
can
be used to do what you seek. You'll need to know the printer device
name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Hi,

My small database application is stored on a network drive. Our
office
has
four floors with several printers on each floor. We select our
default
printer from a list of available printers. We can change our
default
printer, or we can just change printers for a single job via the
Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our
IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
K

Ken Snell [MVP]

Be sure that you use the full code step that I provided. You need

Set Application.Printer = Application.Printers("K030223")


If you just try this:

Application.Printers("K030223")

it will not work.
--

Ken Snell
<MS ACCESS MVP>



Rosemary said:
Hi Ken,

That worked great -- I was able to find the printer I was looking for and
at
least know I was identifying it correctly. This was helpful for me to
learn
about.

The procedure is still not functioning, though, so -- as you mentioned --
I
am contacting my IT dept. to ask them how to get my procedure to "see"
this
printer.

Thanks!


Ken Snell said:
What I suggest you try first is to open the VBE and go to the Immediate
Window. In the window, type this expression and press Enter:

?Application.Printers(0).DeviceName

You'll get a name for the first printer in the collection. Then change
the 0
to a 1, and press Enter. You'll get the name of the second printer.
Continue
until you find the device name that you want, and then use that name in
the
expression we posted earlier.

If you get an error when you put in a number that goes beyond the number
of
printers, then the printer you want either is not mapped/connected to the
PC, or it has an unexpected name that you didn't recognize. In this case,
you'll need to talk with IT to identify the name that you need to use.
--

Ken Snell
<MS ACCESS MVP>


Rosemary said:
I see. Thanks. My line of code looks like this:

Application.Printers("\\geoprint\K030223")

I've also tried it like this:

Application.Printers("K030223")

It's not working yet -- I think I have to ask my IT dept. how to
correctly
write the path to the printer which is named K030223. Is that correct?

Regards,
Rosemary


:

No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see
in
the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer
back
to
the default printer.
--

Ken Snell
<MS ACCESS MVP>



Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the
device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




:

Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object
that
can
be used to do what you seek. You'll need to know the printer device
name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Hi,

My small database application is stored on a network drive. Our
office
has
four floors with several printers on each floor. We select our
default
printer from a list of available printers. We can change our
default
printer, or we can just change printers for a single job via the
Print
screen.

I'd like to code my Print command button so that it always sends
the
report
to the same printer. How can I do this? Do I need to contact
our
IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
G

Guest

Hi Ken,

Yes, I did do that.

Thanks,



Ken Snell said:
Be sure that you use the full code step that I provided. You need

Set Application.Printer = Application.Printers("K030223")


If you just try this:

Application.Printers("K030223")

it will not work.
--

Ken Snell
<MS ACCESS MVP>



Rosemary said:
Hi Ken,

That worked great -- I was able to find the printer I was looking for and
at
least know I was identifying it correctly. This was helpful for me to
learn
about.

The procedure is still not functioning, though, so -- as you mentioned --
I
am contacting my IT dept. to ask them how to get my procedure to "see"
this
printer.

Thanks!


Ken Snell said:
What I suggest you try first is to open the VBE and go to the Immediate
Window. In the window, type this expression and press Enter:

?Application.Printers(0).DeviceName

You'll get a name for the first printer in the collection. Then change
the 0
to a 1, and press Enter. You'll get the name of the second printer.
Continue
until you find the device name that you want, and then use that name in
the
expression we posted earlier.

If you get an error when you put in a number that goes beyond the number
of
printers, then the printer you want either is not mapped/connected to the
PC, or it has an unexpected name that you didn't recognize. In this case,
you'll need to talk with IT to identify the name that you need to use.
--

Ken Snell
<MS ACCESS MVP>


I see. Thanks. My line of code looks like this:

Application.Printers("\\geoprint\K030223")

I've also tried it like this:

Application.Printers("K030223")

It's not working yet -- I think I have to ask my IT dept. how to
correctly
write the path to the printer which is named K030223. Is that correct?

Regards,
Rosemary


:

No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see
in
the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer
back
to
the default printer.
--

Ken Snell
<MS ACCESS MVP>



Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the
device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




:

Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object
that
can
be used to do what you seek. You'll need to know the printer device
name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Hi,

My small database application is stored on a network drive. Our
office
has
four floors with several printers on each floor. We select our
default
printer from a list of available printers. We can change our
default
printer, or we can just change printers for a single job via the
Print
screen.

I'd like to code my Print command button so that it always sends
the
report
to the same printer. How can I do this? Do I need to contact
our
IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
R

Ronald W. Roberts

Rosemary said:
Hi Ken,

Yes, I did do that.

Thanks,



:


Be sure that you use the full code step that I provided. You need

Set Application.Printer = Application.Printers("K030223")


If you just try this:

Application.Printers("K030223")

it will not work.
--

Ken Snell
<MS ACCESS MVP>




Hi Ken,

That worked great -- I was able to find the printer I was looking for and
at
least know I was identifying it correctly. This was helpful for me to
learn
about.

The procedure is still not functioning, though, so -- as you mentioned --
I
am contacting my IT dept. to ask them how to get my procedure to "see"
this
printer.

Thanks!


:



What I suggest you try first is to open the VBE and go to the Immediate
Window. In the window, type this expression and press Enter:

?Application.Printers(0).DeviceName

You'll get a name for the first printer in the collection. Then change
the 0
to a 1, and press Enter. You'll get the name of the second printer.
Continue
until you find the device name that you want, and then use that name in
the
expression we posted earlier.

If you get an error when you put in a number that goes beyond the number
of
printers, then the printer you want either is not mapped/connected to the
PC, or it has an unexpected name that you didn't recognize. In this case,
you'll need to talk with IT to identify the name that you need to use.
--

Ken Snell
<MS ACCESS MVP>




I see. Thanks. My line of code looks like this:

Application.Printers("\\geoprint\K030223")

I've also tried it like this:

Application.Printers("K030223")

It's not working yet -- I think I have to ask my IT dept. how to
correctly
write the path to the printer which is named K030223. Is that correct?

Regards,
Rosemary


:



No.

See this line:
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")

Replace PrinterDeviceNameOfDesiredPrinter with the actual name of the
printer device that you want to use (likely it's the one that you see
in
the
printer dialog window).

The line with Nothing in it must stay as is. That resets the printer
back
to
the default printer.
--

Ken Snell
<MS ACCESS MVP>





Hi Ken,

I am using Access 2002. I would replace the "Nothing" with the
device
name?
E.g.,

Set Application.Printer = L200604

Thanks!




:



Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object
that
can
be used to do what you seek. You'll need to know the printer device
name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>



Hi,

My small database application is stored on a network drive. Our
office
has
four floors with several printers on each floor. We select our
default
printer from a list of available printers. We can change our
default
printer, or we can just change printers for a single job via the
Print
screen.

I'd like to code my Print command button so that it always sends
the
report
to the same printer. How can I do this? Do I need to contact
our
IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub


Rosemary,

Another way to do this, at least in older versions of Access,
is the following.

1. Design the report.
2. Under the File Menu, select Page Setup.
3.Click the Page tab.
4. Select User Specific Printer at the bottom of the page.
5. Click the Printer Button.
6. This will open another dialog box allowing you to select the
printer you want.
7. Click OK for both dialog boxes
8. When completed, under the File Menu and Save the report.

Ron
 
G

Guest

Hi Ken, I was looking at this post and am very interested in the code it
would take to set a specific report to print to a specific printer. I tried
using the code you posted, but I am using Access 2000. Is there anything I
can do to accopmlish this in Access 2000?

Thanks,
DtF

Ken Snell said:
Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that can
be used to do what you seek. You'll need to know the printer device name for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Rosemary said:
Hi,

My small database application is stored on a network drive. Our office
has
four floors with several printers on each floor. We select our default
printer from a list of available printers. We can change our default
printer, or we can just change printers for a single job via the Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 
A

Allen Browne

The code Ken posted requires Access 2002 or 2003.

Try this code from Albert Kallal:
http://www.members.shaw.ca/AlbertKallal/msaccess/printch2k.zip

(PMFJI, Ken: I don't see the original post here.)

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

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

DrewTheFather said:
Hi Ken, I was looking at this post and am very interested in the code it
would take to set a specific report to print to a specific printer. I
tried
using the code you posted, but I am using Access 2000. Is there anything
I
can do to accopmlish this in Access 2000?

Thanks,
DtF

Ken Snell said:
Are you using ACCESS 2002 or 2003? If yes, these versions have an
Application.Printers collection and an Application.Printer object that
can
be used to do what you seek. You'll need to know the printer device name
for
the desired printer to use it:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
Set Application.Printer =
Application.Printers("PrinterDeviceNameOfDesiredPrinter")
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Set Application.Printer = Nothing
End If

End Sub

--

Ken Snell
<MS ACCESS MVP>

Rosemary said:
Hi,

My small database application is stored on a network drive. Our office
has
four floors with several printers on each floor. We select our default
printer from a list of available printers. We can change our default
printer, or we can just change printers for a single job via the Print
screen.

I'd like to code my Print command button so that it always sends the
report
to the same printer. How can I do this? Do I need to contact our IT
people?

The code for my Print Record command button is below.

Many thanks,

---------------------------------------------------
Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[JobId] = " & Me!JobId
stDocName = "Job Ticket"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

End If

End Sub
 

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

Similar Threads


Top