Kenny,
What I need is up to 20 or so command buttons that will, when clicked, enter something that would normally come from the key board.
Thanks for the clarification. So you want a sort of auto-text facility (like in Word), where the user can assign a word or phrase to a button, and have that text entered into an editing control when the button is clicked.
One way to do that would be with the KEYBOARD command. You can use that command to programmatically type the text. But there are some complications.
You'd have to have some way of knowing which control is to receive the text. You can't rely on the ActiveControl property, because that would simply point to the command button. You'd also need to know where the insertion point is. You could determine that from the SelStart property, but you'd have to store that before the editing control loses focus. The command button's Click event would have to set focus back to the editing control, put the insertion point in the correct place, and then issue the KEYBOARD command.
It's probably do-able, but difficult.
May I suggest an alternative? Instead of using command buttons, consider using a shortcut menu. The menu would appear when the user right-clicks within the editing control. It could include all the auto-text entries, possibly arranged in cascading sub-menus to make navigation easier. The user would click on a sub-menu entry (or use an associated shortcut key) to enter the text at the insertion point.
The advantage of a sub-menu over command buttons is that it works within the context of the control you are editing. The control always retains focus and keeps track of its own insertion point. The code called from the menu would simply do the KEYBOARD command. It would also be easier to make it generic (all your text boxes and edit boxes could have such a menu), plus it would reduce clutter on the form.
Just a thought.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro tips, advice, training, consultancy
Custom software for your business