>hi every one.
>I have experienced very awesome situation about on key label command.
>
>I have a mainform and subform in my program.
>and I need to assign hot keys to 2 forms...
>
>the first mainform has assigned in the init event.
> => on key label 'ALT+N' mainform.cmdAdd.click
>
>and subform has assigned in the form's gotfocus event.
> => push key
> on key label 'ALT+N' subform.cmdAdd.click
>
> subform has assigned in the form's lostfocus event.
> => pop key ( restore mainform's hot key assignment )
>
>now....it seems very works well....
>( ** all of cmdADD's command is 'append blank' command... ** )
>
>But!!!!!!
>Sometimes or Manytimes, it broked my subform's table indexes....
>I think that it may be memory curruption? or
>in my fault?
ON KEY LABEL commands are interprocess commands. That means OKL commands will interrupt running code to run their own, as you have found out, this can cause intersting and troubling results.
A more dependable way to do what you want to do is to put your code in the Form.Keypress event and set Form.KeyPreview = .T.
But since the hot key you wantto use is an 'ALT' combination, and 'ALT' combinations don't fire the Form.Keypress event, you can use another trick:
put another button on each form and move it off screen so it can't be seen. Set the button's caption to \<N and put THISFORM.cmdAdd.Click() in the new button's click event.
Of course, an easier way would be to change your hot key to ALT+A, and then change the add button's caption to \<A.
Erik Moore
Clientelligence