PDA

View Full Version : Prevent Tab and Enter Subform



jmentor
05-21-2006, 05:57 AM
I have a main form with a subform datasheet style.
I need to prevent users from tabbing out of the subform or pressing enter to move to the main form. At the moment both tab and enter allow users back onto the main form where there are delete buttons etc.
Thanks
Mentor

OBP
05-22-2006, 08:14 AM
Is this a secured database?
Do the users start off in the Main form or the subform?
If the last field of the subform is where they tab or press enter to move on to the main form then you can put some simple VB code in the field's "After update" event procedure that returns "Focus" back to the first field on the sub form.
The code is

Forms!Employees!EmployeeID.SetFocus

you just need to replace the Employees and EmloyeeID with your subform's name and the first field on the subform.
You could also place it in the field's "On Exit" event procedure as well in case they do not update the field.