1
votes

I have code in my Form's Property Sheet [On Key Down] event which sets the focus to the first field in a subform if the user presses tab in the last field of header data.

It works fine as long as the user makes no mistakes in entering data in the last header field. That field is a date and if the user enters a badly formatted date and presses tab, they get a run-time error 2110 "Access can't move the focus to the control xxx"

Then, if they press end, it will let them go back and adjust the date but it seems to hang on to the initial bad value and repeatedly say "The value you entered isn't appropriate for the input mask." even if it is now a good value.

1

1 Answers

0
votes

You should be able to just set the Subform as the next control in your tabbed order instead of creating your own method for setting focus to the Subform. In the Subform just make sure that the field in question is set to the be the first in the tab order of the Subform.

I think this is kind of one of those "Why reinvent the wheel?" type of scenarios. For more information about setting tab order you can read through: https://support.office.com/en-in/article/Set-the-tab-order-for-controls-ec2943d9-8b07-4778-8157-c1785a0dd438

Example:

Parent Form tab order can be set to: Parent.ctrl1, Parent.ctrl2, Parent.ctrl3, Parent.subform1

Then the Subform tab order can be set to: Subform.ctrl1, Subform.ctrl2, Subform.ctrl3... etc

In this scenario when you tab to Parent.subform1 you will then change to the tab order of the subform and go to Subform.ctrl1