Convert SendKeys Key Combinations
See Also
If you're converting a version 1.x or 2.0 database to Microsoft Access 2000, changes in some dialog boxes and menus may require you to recode the SendKeys statement or SendKeys action. For example, the Add-ins submenu has been moved from the File menu to the Tools menu, and the previous Import, Export, and Attach submenus on the File menu have changed to the Get External Data and Save As/Export submenus. Because changes like this are likely to occur for each new version of Microsoft Access, it's a good idea to avoid using the SendKeys statement or action to carry out commands or fill in dialog boxes whenever possible.
Here are some tips you can use to avoid using the SendKeys statement or action:
- Before you use the SendKeys statement or action to carry out a menu command, check for an equivalent macro action or Visual Basic method. Most commands that are commonly carried out by a menu command or option have an equivalent action or method. For example, you can now use the Dropdown method of a combo box rather than the code
SendKeys "{F4}"
.
- If a menu command doesn't have an equivalent action or method, use the RunCommand action rather than the SendKeys statement or action to carry it out.
- Avoid using the SendKeys statement or action to set options in the Options dialog box. New versions of Microsoft Access have new and changed options, so the code in your SendKeys statement or action could easily break. Instead, use the GetOption and SetOption methods.
- When you use the SendKeys statement to carry out an action, consider referencing the built in key-code constants or declaring constants for the values in your SendKeys statement. Defining your keystrokes as constants makes updating your code easier in the future.
- In Microsoft Access version 2.0, you can enclose the Keystrokes argument of the SendKeys action in quotation marks, but it isn't required. If you enclose this argument in quotation marks in subsequent versions of Microsoft Access, an error occurs. To use quotation marks in the Keystrokes argument, you must use two sets of quotation marks, as in Michael ""Mick"" Suyama. An error can also occur if the Keystrokes argument contains incorrect syntax, misspelled text, or other values that aren't appropriate for the window the keystrokes are sent to.