Unanswered: Populating list box's row source with printer names
I would like a form to populate a list box's row source with all available printer names on the form's open event. I found the following Public Function but I'm not sure how to call it in my form (also not sure if code is VBA or VB). Can someone point me in the right direction? Thanks!
Public Function PopulateListControlWithPrinters(ListControl As _
Object) As Boolean
On Error GoTo errHandler:
Dim l As Long
Dim lCount As Long
lCount = Printers.Count
If lCount = 0 Then
ListControl.AddItem "(No Printer Installed)"
For l = 0 To lCount - 1
PopulateListControlWithPrinters = True
PopulateListControlWithPrinters = False
Put that code in a public module (create one if you don't already have one you can put this in). On the form's open event, do something like:
Dim blnPopulated as boolean
blnPopulated = PopulateListControlWithPrinters(Forms!frmName!ctlName)
if not blnPopulated then
Msgbox "Printer List Error",vbokonly + vbexclamation,"You have failed. F--"
Obviously you'll have to substitute your form's name and your control's name where I've bolded in the code.