You can do many things, the question is what makes most sense.
The textbox InteractiveChange event happens after any single change of the textbox value, ProgrammaticChange likewise happens when this value change is caused programmatically. Then you could act on Valid and LostFocus events triggered by TAB or ENTER. That also will depend on SET CONFIRM ON/OFF. So there are your technical aspects to consider and solve this. I think they are self-explanatory by their name, mostly. SET CONFIRM means your input will need to finish with ENTER, you confirm your input to be complete by ENTER, not by TAB or even moving focus by mouse click.
In the simplest "hack" call button.click as the code of the InteractiveChange event of the ID input textbox and you have your automation.
Let me argue a bit further, though: In an interface where TAB and/or ENTER finish input of an ID and move focus to that execute command button, all you actually save by automatic execution is pressing SPACE and TAB or ENTER. Because notice, SPACE does trigger the click event, too. You don't need to switch from keyboard to mouse to enter your id. Besides that, ENTER is a usual way to signal complete input and as said you can make ENTER cause events of the textbox, too. You could also check for ENTER key in the KeyPress event. And yes, you can also spare that if you go for the InteractiveChange processing any ID.
But then think of an even worse case that's also quite common: If valid IDs are from a sequence of numbers. Wanting to enter 10432 you go through 1,10,104,1043 and finally 10432. Do you really want to automatically trigger the execution of actions for all the smaller and all valid IDs, too?
So some signal of complete input is not only necessary but also usual in any case, I don't see where that wouldn't matter. There is a category of programs that don't let you enter every input: Games. You affect your current state with some joysticks or such, you don't ENTER after every joystick movement, of course. But then there are a lot of point-and-click interfaces in games, too. But that's a different situation, you don't depend on the exactness of inputs, as you interactively change and correct them. Different beast of an interface, but that doesn't translate to business applications.
I'd recommend SET CONFIRM OFF even though it solves the ENTER=confirming input elegantly, it stops the user from interrupting his id input and do something completely different (in the same VFP application), maybe because a phone call comes in. So I recommend to never put the user into some enforced workflow they have to finish before starting anything else, even such a simple workflow as finishing the id input. And there a command button actually is the easiest way to separate the confirmation of input and action that should cause.
In a touch interface, you may have a barcode scanner for the actual input and it's easy to configure them to send ENTER after the scanned barcode, too. ENTER or TAB/SPACE or ENTER/SPACE is easy to get into your finger memory, too.
I would accept the strategy or specification to react on ENTER anyway. But let it be softer than SET CONFIRM ON, let it work through normal focus change. You could also set the input max length to fit an id/barcode length, by the way. Or specifically handle ENTER in Keypress, as said.
Bye, Olaf.
Olaf Doschke Software Engineering