>I want to be able to hit enter in a textbox and the code to execute for that textbox and then return focus to that textbox. I have two lines of code in the valid event but when I press enter I go to the next control on the form, I can't set focus to the textbox in the valid event. How would I do this?
>
>Thanks,
Tyler,
While both Tom and Nadya are correct, you can also return a logical value from the valid event to prevent the cursor from leaving a control. I prefer using this technique over using a numeric for a couple of reasons. Chiefly because I can simply assign the return value in the function based on a logical expression. For example, if the control needs to accept a date field and the date field needs to be a date in the future: llresult = (This.Value > DATE()) acheives the desire effect.
You should also know that return a numeric value from the Valid event can control where the cursor goes next.
George
Ubi caritas et amor, deus ibi est