Trying to validate data in a text box control on an Access 2007 form using the "on change" event and/or "after update" event. The text box (e.g. MyTxtBox) contains a date that
1) must be within a range based on the NOW() function date, and
2) must be <= another date (may be NULL) in a text box on the same form
Data for the text box can come from a date picker or keyboard entry.
The "on change" event for the MyTxtBox.value has the prior value (either NULL or a date) and not the date from keyboard entry or date picker.
The "after update" event is invoked if MyTxtBox loses focus and that handler has the desired MyTxtBox.value. However, if the date value does not meet the criteria (a modal msgbox is displayed) and if the user wishes to try again, the following happens:
1) MyTxtBox.Value is successfully set to NULL, and
2) an attempt to keep the focus on MyTxtBox by using MyTxtBox.SetFoc us fails (while debugging, no error messages occurred and it appears to execute the SetFocus successfully but didn't set the focus).
How can I get the new value of MyTxtBox, validate this value, and keep focus on MyTxtBox if a correction is warranted?
1) must be within a range based on the NOW() function date, and
2) must be <= another date (may be NULL) in a text box on the same form
Data for the text box can come from a date picker or keyboard entry.
The "on change" event for the MyTxtBox.value has the prior value (either NULL or a date) and not the date from keyboard entry or date picker.
The "after update" event is invoked if MyTxtBox loses focus and that handler has the desired MyTxtBox.value. However, if the date value does not meet the criteria (a modal msgbox is displayed) and if the user wishes to try again, the following happens:
1) MyTxtBox.Value is successfully set to NULL, and
2) an attempt to keep the focus on MyTxtBox by using MyTxtBox.SetFoc us fails (while debugging, no error messages occurred and it appears to execute the SetFocus successfully but didn't set the focus).
How can I get the new value of MyTxtBox, validate this value, and keep focus on MyTxtBox if a correction is warranted?
Comment