N
NewUser
I am trying to create a method in which an end user can select a report
and printer from a form. I was able to populate a combo field with the
available printers using the code below. However I can not figure out
how to assign the selected print to the selected report. I assume that
I need to add code to the report so that ON OPEN, the printer name can
be updated from the form field. Any help would be appreciated.
' Variable to hold the default printer index.
Dim strDefaultPrinter As String
' Variable to hold the printer object.
Dim prt As Printer
' Variable to hold the report object while cycling through the
AllReports collection.
Dim accObj As AccessObject
' Fill the printer list. Make sure the RowSource is empty.
Me!cmbPrinter.RowSource = ""
' Cycle through the printers installed on the machine and add them to
the combo box.
For Each prt In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me!cmbPrinter.AddItem prt.DeviceName
Next
' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName
' Set the combo box to the default printer.
Me!cmbPrinter = strDefaultPrinter
and printer from a form. I was able to populate a combo field with the
available printers using the code below. However I can not figure out
how to assign the selected print to the selected report. I assume that
I need to add code to the report so that ON OPEN, the printer name can
be updated from the form field. Any help would be appreciated.
' Variable to hold the default printer index.
Dim strDefaultPrinter As String
' Variable to hold the printer object.
Dim prt As Printer
' Variable to hold the report object while cycling through the
AllReports collection.
Dim accObj As AccessObject
' Fill the printer list. Make sure the RowSource is empty.
Me!cmbPrinter.RowSource = ""
' Cycle through the printers installed on the machine and add them to
the combo box.
For Each prt In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me!cmbPrinter.AddItem prt.DeviceName
Next
' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName
' Set the combo box to the default printer.
Me!cmbPrinter = strDefaultPrinter