Article ID: 109958
Article Last Modified on 5/6/2003
APPLIES TO
- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition
This article was previously published under Q109958
Novice: Requires knowledge of the user interface on single-user computers.
SYMPTOMS
If you use the SendKeys statement in Access Basic to fill a dialog box and Microsoft Access yields the computer's processor to another Windows process before the dialog box appears, the sent characters will be lost.
One situation where this might occur would be filling a report name in the Print dialog box when you are printing a report to a file.
RESOLUTION
To minimize the chance of losing sent keys, make your queries as short as possible. When a query takes a long time to run, Windows has more time to interrupt the task to serve another Windows process. By shortening your queries, you give Windows less time to interrupt.
If this problem occurs when you are printing to a file, try printing directly to the file through your printer driver. If your printer driver supports this, set it to print your report directly to a file instead of using Microsoft Access to do this.
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access versions 1.0, 1.1, and 2.0. This problem no longer occurs in Microsoft Access version 7.0.
MORE INFORMATION
Steps to Reproduce Problem
- Set up a Windows printer to print to FILE. In Microsoft Windows 95 open the Printer folder and click on New Printer. Follow the wizard instructions. In Windows 3.x, use the Windows Control Panel, double- click on printers, select or add your printer click Connect. Select FILE from the Ports list and click OK.
- Start Microsoft Access and open the sample database Northwind.mdb (In Access 2.0 or earlier, NWIND.MDB.)
- Copy the query "Employee Sales by Country" to "Employee Sales by Country Backup". (In Access 2.0 and earlier, this query will be called "Employee Sales by Country (Parameter)")
- Open the "Employee Sales by Country" query and remove the parameters from the Shipped Date field in the query grid.
- Drag the Employee ID field to the query grid and then type 1 in its Criteria row. Close and save the query.
Create the following new macro and save it as "Print Employee Sales by Country":
SendKeys Keystrokes: text.txt Wait: No SendKeys Keystrokes: {enter} Wait: No OpenReport Report: Employee Sales By Country Mode: Print
- Set the report "Employee Sales by Country" to print to the printer on port FILE. To do this, in Microsoft Access for Windows, select Page Setup from the File menu. Select the Page tab. Select "Use Specific Printer" and select the printer you set up in step 1. Click OK. In Microsoft Access, version 2.0 or earlier, select Printer Setup from the File menu and select specific printer. Select the printer you set up in Step 1 above and click OK. Save the report.
- Run the "Print Employee Sales by Country" macro. In Microsoft Access for Windows 95 or Microsoft Access, version 1.x, the sent keys work correctly. In version 2.0, the sent keys are lost.
- Remove the Employee ID field from the query and run the macro again. Note that the sent keys are again lost in Microsoft Access, version 2.0
REFERENCES
For information on setting up a printer in Windows 95, search for "Printer, setting up a printer" using the Windows 95 Help menu.
For more information about setting up a printer, search for "SendKeys action" or "printing, Print dialog box options" using the Microsoft Access 2.0 Help menu.
For more information about setting up a printer, search for "Print Setup" or "Sendkeys" using the Microsoft Access 2.0 Help menu.
For more information about setting up a printer in Microsoft Windows 3.x, press F1 while in the Printer Setup window.
Additional query words: programming timeout
Keywords: kbbug kbprint KB109958