Printer
Printerwill allow you access to the default printer properties. You can view the name of the
default printer using the following code:
MsgBox Printer.DeviceName
Printers
Printersis a collection of all the printers available to the application and contains all the
properties for each printer. You can iterate through the collection with the following code:
Dim Prt As Printer
For Each Prt In Printers
MsgBox Prt.DeviceName
Next Prt
This will display all the names of the print devices available and will mirror the printer
drop-down in the standard Print dialog in Microsoft Office.
Quit
As the nameQuitimplies, this will quit the application. It is quite dangerous to use because
you will be given no warnings, and nothing outstanding will be saved off. You can also use
DoCmd.Quit, which does provide warnings.
References
TheReferencescollection contains all the references to external object libraries that are used
within VBA. You can iterate through the collection with the following code:
Dim Reff As Reference
For Each Reff In References
MsgBox Reff.Name
Next Reff
Reports
TheReportscollection is very similar to the Forms collection discussed earlier. It only
contains reports that are open and loaded, but it does give you access to the properties of
controls on the report. You can iterate through theReportscollection as follows:
Dim Rep As Report
For Each Rep In Reports
MsgBox Rep.Name
Next Rep
Chapter 15: The Main Objects 199