I have encountered a problem which I cannot solve and hope the community out there can assist. The Hackers Guide warns that Setfocus() can do strange things and I guess this is one of them.
I have a generic entry container which is used on a number of screens. It has 4 textboxes which are entered in turn and when the 4th is complete, they all reset to defaults and go back to box 1. This all works fine using the tab order. The problem is that to leave the container, the user presses ENTER on the first textbox and if it is empty (the default) the cursor needs to move outside the container - usually to a command button. Easy enough with a mouse but mice aren't always around and both entry options need to be available.
So: txtbox1.Keypress method:
if nKeycode = 13 and empty(this.value) this.parent.parent.cmdCommandButton.Setfocus() endif
This method hits the correct commandbutton but it causes the commandbutton Keypress() to respond to an enter rather than waiting for a response which then triggers the click() event. I have checked with wait windows and the Keypress method is firing immediately with nkeycode = 13. i.e. as if ENTER had been pressed on the control.
I have tried stuffing blanks into the keyboard buffer etc...
any ideas on causes, solutions would be appreciated
©2001 graeme thomson |