Prior to Access 2002, there was no easy way to programmatically control the printer in the applications that you built. Unlike other aspects of Access in which Microsoft provided you with objects, properties, methods, and events that you could easily manipulate, programmatically controlling the printer in versions prior to Access 2002 involved rolling up your sleeves, and talking at a low level to operating system objects.
Fortunately, Access 2002 introduced a new Printer object and a Printers collection. The Printer object greatly facilitates the process of programmatically manipulating a printer. The Printers collection allows you to loop through all the Printer objects and perform a task.
The Printers collection consists of individual Printer objects. You use a Printer object to control each printer in the Printers collection. Listing 10.13 provides an example of the Printer object.
Listing 10.13 begins by instantiating a Printer object. It points the Printer object at the first printer in the Printers collection. It then retrieves the DeviceName, Port, ColorMode, and Copies properties of the printer. These are four of the many properties included for the Printer object. Other properties include the LeftMargin, RightMargin, TopMargin, BottomMargin, Orientation, and PrintQuality properties. Most properties of the Printer object are read/write. This means that you can programmatically manipulate the properties at runtime, easily controlling the behavior of the printer.
Using the Printers collection, you can loop through all the printers available for a user, programmatically manipulating each one. Listing 10.14 provides an example. It is found in frmPrinterObjectAndPrintersCollection on the sample code CD.