
Bound combo box won't let be cancel/undo, continually generating error messages
Hi,
I have a form which is bound to a table. On this form is a combo box which
is bound to an numeric ID in the bound table, however the values it lists
are gained from a query. The bound column of the combo is also a numeric ID
value, but hidden by setting the columns width to zero. The field that the
combo box is bound to in the table is required.
The problem:
If a user selects a value from the combo box does some other stuff
on the form, but then deletes the text contents of the combo box,
this interaction sets the combo boxes value to null. This causes an
error saying the field can not be null if you then try to click on/tab to
another control.
What I've tried:
In the BeforeUpdate event of the combo box
1) I have set the combo box value to 0 or to 1 this
causes an error saying the macro of function set to the before update or
validation rule for this field is preventing "name
of system" from saving record. (NOTE : The field in the bound table, doesn't
have a validation rule).
2) Set Cancel = True, this causes an error when clicking
on/tabbing to another control saying the value must be saved first.
3) Running the Undo method of the form and then setting
focus to another control, see error described in (2).
4) Running the Undo method of the combo box itself and
then setting focus to another control, see error described in (2).
5) Setting Cancel = True, Running Undo of combo box,
Running Undo of form and then setting focus to another control,
see error described in (2).
Even if I don't use set focus the error as in (2) occurs as soon as
you click on another control or press TAB.
Does any one know how to get around this ? I know it is unlikely that a user
would do this with a combo box, but you never know and I want this form to
be as bullet proof as possible.
Regards
Peter Row