Set and Retrieve the Name of the Default Output Device

Problem

Windows allows you to install a number of printer drivers, but one of them must always be denoted as the default printer. Although Windows provides its own concept of its default printer, Access maintains its own, independent default printer. You’d like to be able to control which printer Access thinks is the default printer, perhaps even choosing from a list of all the installed printers. Is there a way to do this from within Access?

Solution

Windows maintains its own list of available printers and stores information about the default printer. When Access starts up, it automatically uses Windows’s default printer as its own default printer. Access’s Application object provides a Printer property. Setting this property to refer to an item within the Printers collection allows you to control the default printer for all Access objects.

Tip

In Access, you always have the choice of printing an object to the default printer or to a specific printer. None of the techniques shown in this chapter that allow you to change the output destination will work if you set up your reports to print to a specific printer. In addition, printing to a specific printer will almost always lead to trouble if you distribute your applications to end users who may or may not have the same printer available. We suggest that, if possible, you set your reports so that they all print to the default printer.

To create a combo box in your own application ...

Get Access Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.