Exiting a ComboBox when the entry is not in the list

J

John S. Ford, MD

I'm working in Access 97. I have a ComboBox on a form. When a user tries
to enter a value that is not one of the choices, an error occurs: "The text
you entered isn't an item in the list." If the user tries to delete his
choice and get out he gets another error: "You tried to assign the Null
value to a variable that isn't a Variant data type."

The problem with the second error is that there appears to be NO way the
user to escape the ComboBox even if he tries to delete his entry completely
without the same error message coming up. The only way to get out is to
select a random choice from the list and then delete it later.

Is there a more graceful way of exiting this situation? Can I trap one (or
both) of these errors and right an error handler with my own messages? How
do you pros handle this problem?

John
 
D

Dirk Goldgar

John S. Ford said:
I'm working in Access 97. I have a ComboBox on a form. When a user
tries to enter a value that is not one of the choices, an error
occurs: "The text you entered isn't an item in the list." If the
user tries to delete his choice and get out he gets another error:
"You tried to assign the Null value to a variable that isn't a
Variant data type."

The problem with the second error is that there appears to be NO way
the user to escape the ComboBox even if he tries to delete his entry
completely without the same error message coming up. The only way to
get out is to select a random choice from the list and then delete it
later.

Is there a more graceful way of exiting this situation? Can I trap
one (or both) of these errors and right an error handler with my own
messages? How do you pros handle this problem?

The user can escape the combo box by pressing ... wait for it ... the
Escape key. Really. :)

I agree, by the way, that this isn't all that obvious to the user. The
problem is that just deleting what the user entered doesn't return the
combo box to its untouched state; it looks to Access like you're trying
to change the value of the bound field to Null or to a zero-length
string. Pressing the Escape key or clicking the Undo toolbar button or
menubar item returns the control to its original state. A user familiar
with the standard Windows user interface guidelines will probably figure
it out.

You can write an event procedure for the combo box's NotInList event,
and in that procedure you can display your own message while suppressing
the standard message. Your message could explicitly advise the user on
how to undo the entry.
 
Top