ACC: Using SendKeys to Simulate Hot Keys Fails If in Uppercase
ID: Q140789
|
The information in this article applies to:
-
Microsoft Access versions 2.0, 7.0, 97
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.
- Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0.)
- Open the Customers form in Design view.
- Add a command button to the form with the following event procedure:
Sub Command10_Click()
SendKeys "^F"
End Sub
- 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.
- 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
- 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."
Additional query words:
Keywords : kbprg MdlGnrl
Version : WINDOWS:2.0,7.0,97
Platform : WINDOWS
Issue type : kbbug