ACC2000: Use of SendKeys to Simulate Hot Keys Is Unsuccessful if Characters Are Uppercase (210197)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q210197
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you use the SendKeys statement to send keystrokes to the user interface in Microsoft Access, and you use the CTRL key designation (^) in combination with uppercase characters, the action is unsuccessful, although you receive no beep to indicate an invalid key combination.

RESOLUTION

Use lowercase letters in SendKeys statements when you simulate user interface key combinations that use the CTRL key designation.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To create a simple function to send the CTRL+F key combination to the user interface to open the Find window, follow these steps:

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Start Microsoft Access and open the sample database Northwind.mdb or the sample project NorthwindCS.adp.
  2. Open the Customers form in Design view.
  3. If the Toolbox is not visible, on the View menu, point to Toolbars, and then click Toolbox.
  4. If the Control Wizards control on the Toolbox is selected, click it to clear it.
  5. Click the Command Button control, and then click in the upper-right area of the Detail section of the form.
  6. If the property sheet is not visible, on the View menu, click Properties.
  7. On the property sheet, click the Event tab, and then click Event Procedure in the OnClick list.
  8. Click the Build button and type the following line in the command button's OnClick procedure:
    SendKeys "^F"    ' note upper case "F"
    					
  9. Open the Customers form in Form view, and then click the command button.

    Notice that the Find window does not appear and no beep is generated to indicate an invalid key combination.
  10. Open the Customers form in Design view, and then change the event procedure on the command button to the following:
    SendKeys "^f"    'Note the lower case "f"
    					
  11. Open the Customers form in Form view, and then click the command button.

    Notice that the Find window now appears as expected.

REFERENCES

For more information about the SendKeys statement, click Microsoft Access Help on the Help menu, type sendkeys in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbbug kbProgramming KB210197