Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to specify a printer via VB?

2 views
Skip to first unread message

Dennis

unread,
Feb 6, 2006, 4:29:02 PM2/6/06
to
I need to display a list of printers installed on a PC, and allow the user to
select one of them for a report. I need to be able to do this from VB (long
story). Can someone point me in the right direction?

Thanks a million!

Ofer

unread,
Feb 6, 2006, 4:29:28 PM2/6/06
to
Check this link

http://www.mvps.org/access/reports/rpt0009.htm

--
\\// Live Long and Prosper \\//
BS"D

Dennis

unread,
Feb 6, 2006, 4:29:59 PM2/6/06
to
That link was helpful, but not exactly what I need. I need to display a list
of printers, and allow the user to select one . I don't need other printer
properties like paper type, page size, etc. Just a list of names. When the
user selects a name, that printer is used for the specific report. Access
2002.

Thanks!

Gina via AccessMonster.com

unread,
Feb 6, 2006, 5:03:48 PM2/6/06
to
Create a form with a listbox on it and use the following code:

Private Sub Form_Load()
Dim intCounter As Integer

For intCounter = 0 To Application.Printers.Count - 1
Me.lstPrinters.AddItem Application.Printers(intCounter).DeviceName(),
intCounter
Next intCounter

End Sub

Dennis wrote:
>That link was helpful, but not exactly what I need. I need to display a list
>of printers, and allow the user to select one . I don't need other printer
>properties like paper type, page size, etc. Just a list of names. When the
>user selects a name, that printer is used for the specific report. Access
>2002.
>
>Thanks!
>

>> Check this link
>>
>[quoted text clipped - 5 lines]
>> >
>> > Thanks a million!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-reports/200602/1

Dennis

unread,
Feb 6, 2006, 5:31:21 PM2/6/06
to
Worked like a charm. Now, is there an easy way to set the selection as the
printer for that report ONLY?

Thanks!!

Gina via AccessMonster.com

unread,
Feb 6, 2006, 5:43:31 PM2/6/06
to
What I did in my application was included a second list box with the names of
the reports that the user could print then I used the following code to set
the printer and output the report.

Dim stDocName As String

stDocName = Me.lstReports.Value()

If Len(stDocName) > 0 Then
'open the report in a hidden window
DoCmd.OpenReport stDocName, acViewPreview, , , acHidden

'set up printer
Reports(stDocName).Printer = Application.Printers(Me.lstPrinters.
ListIndex())
Reports(stDocName).Printer.Copies = Me.txtNumCopies.Value()

DoCmd.OpenReport stDocName, acNormal
End if

Its seems a bit convoluted, but it works. There is probably a much better way
of doing it.....

Gina

Dennis wrote:
>Worked like a charm. Now, is there an easy way to set the selection as the
>printer for that report ONLY?
>
>Thanks!!
>

>> Create a form with a listbox on it and use the following code:
>>

>[quoted text clipped - 21 lines]

Dennis

unread,
Feb 6, 2006, 5:56:06 PM2/6/06
to
Thanks a million! That should do it!
0 new messages