Help and Support
 

powered byLive Search

ACC: How to Change a Report's Printer Using Code

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:129397
Last Review:August 17, 2007
Revision:2.3
This article was previously published under Q129397
On This Page

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

You can change the printer for a report or form in two ways:
You can change the Microsoft Windows default printer.
You can set the PrtDevNames and PrtDevMode properties.
This information supplements the Microsoft Access Help Topic about the PrtDevNames property.

Back to the top

MORE INFORMATION

Method 1: Changing the Microsoft Windows Default Printer

In the Page Setup (or Print Setup in version 2.0) dialog box, you can choose whether forms or reports are printed by either a default printer or a specific printer. If you choose a default printer, the form or report is printed to the Microsoft Windows default printer. If you want to change to another default printer, you must change the Microsoft Windows default printer.

To change the Microsoft Windows default printer using Visual Basic code (or Access Basic code in version 2.0 or earlier), use WriteProfileString to change the Device= entry of the Microsoft Windows section of the Win.ini file.

Back to the top

Method 2: Setting the PrtDevNames and PrtDevMode properties

The PrtDevNames property stores the name of the printer, and the PrtDevMode property stores the driver information. Both of these properties need to be changed in order to change the printer driver. If the PrtDevMode property does not match the PrtDevNames property (that is, the PrtDevMode property describes a different driver than the PrtDevNames property) a General Protection (GP) Fault may occur.

To change the printer driver, you must do the following:
Open a form or report in Design view.
Set the PrtDevNames property.
Retrieve and set the PrtDevMode property.
In order to set the PrtDevMode property to the appropriate structure, the driver information must be obtained. There are several ways to obtain this information:
Retrieve the information from a previously saved form or report that uses the desired printer.
Call the driver and retrieve the structure. In order to call the driver, a separate DLL is needed. This is because calls to functions in outside files must be declared ahead of time and the driver name will not be known. Instead, call a DLL that determines the correct printer driver to call and retrieves the DevMode structure.
Use the Windows Print Common Dialog.

Back to the top

REFERENCES

For more information about PrtDevMode and PrtDevNames, search for "PrtDevMode property" or "PrtDevNames property," using the Microsoft Access 97 Help Index or please see the following web site:

http://msdn2.microsoft.com/en-us/library/Aa207072(office.10).aspx (http://msdn2.microsoft.com/en-us/library/Aa207072(office.10).aspx)

For more information about WriteProfileString, the Win.ini, and the Default Printer in Windows 95, consult the Microsoft Developers Network CD-ROM (MSDN).

Back to the top


APPLIES TO
Microsoft Access 1.0 Standard Edition
Microsoft Access 1.1 Standard Edition
Microsoft Access 2.0 Standard Edition
Microsoft Access 95 Standard Edition
Microsoft Access 97 Standard Edition

Back to the top

Keywords: 
kbhowto kbprint KB129397

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.