ACC: Using SendKeys to Simulate Hot Keys Fails If in Uppercase (140789)



The information in this article applies to:

  • Microsoft Access 2.0
  • Microsoft Access for Windows 95 7.0
  • Microsoft Access 97

This article was previously published under Q140789

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

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 fails silently.

RESOLUTION

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

STATUS

This behavior is by design.

MORE INFORMATION

The following example uses a simple function to send the CTRL+F key combination to the user interface to open the Find window.

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb (or NWIND.MDB in version 2.0). You may want to back up the Northwind.mdb (or NWIND.MDB) file and perform these steps on a copy of the database.
  1. Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0.)
  2. Open the Customers form in Design view.
  3. Add a command button to the form with the following event procedure:
          Sub Command10_Click()
             SendKeys "^F"
          End Sub
    						
  4. Open the Customers form in Form view, and then click the command button. Note that the Find window does not appear and no beep is generated to indicate an invalid key combination.
  5. Switch the Customers form to Design view, and change the event procedure on the command button to:
          Sub Command10_Click()
             SendKeys "^f" 'Note the lower case "f"
          End Sub
    						
  6. Open the Customers form in Form view, and then click the command button. Note that the Find Window now appears as expected.

REFERENCES

For more information about the SendKeys statement, search the Help Index for "SendKeys statement."

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbbug kbProgramming KB140789