> I am a new programmer with a question about comboboxes. My combo has the
> Limit To List property set to Yes. When I enter a value not on the list, I
> get the standard Access message, "The text you entered isn't an item... " .
> I'm trying to trap this error so I can use my own custom message, but no luck
> yet. How do I go about doing this?
hi swas
Your suggestion to use the On NotInList allowed me to add my own error
message, but then the standard system message followed. I tried to turn this
off with DoCmd.SetWarnings False, but no luck. Any ideas?
> Terry,
>
[quoted text clipped - 11 lines]
> > I'm trying to trap this error so I can use my own custom message, but no luck
> > yet. How do I go about doing this?
swas - 21 Mar 2007 02:14 GMT
Terry,
There would be a few ways, depending on how you want your form to interact
with the user.
If you just want to limit to list, then the Access error is probably
suitable alone.
If you want to have your own error, then you would need to leave the
combobox in a state that is suitable for Access to then accept. Examples
would be add the new value to the combobox After validating any other info),
or set the combobox to a blank "", or restore the combo.oldvalue which is the
previous value it was set to (combo = combo.oldvalue). Setting combo.undo
should have the same effect as the latter.
Unfortunately I am not a programmer, so sorry if this sounds vague... but
happy to help whare I can.
swas
> hi swas
> Your suggestion to use the On NotInList allowed me to add my own error
[quoted text clipped - 16 lines]
> > > I'm trying to trap this error so I can use my own custom message, but no luck
> > > yet. How do I go about doing this?
terry w - 21 Mar 2007 02:49 GMT
very helpful suggestions. Thanks
Marshall Barton - 21 Mar 2007 16:08 GMT
You need to decide what you want to do in that situation.
You might want to open another form (in dialog mode) to add
the item to the list, or, if the table is a simple list, add
the new value directly to the table, or you might want to
discard the offending value (Me.combo.Undo).
In all of those cases, you will want to set the NotInList
event procedure's Response argument to either
acDataErrorAdded or acDataErrorContinue.

Signature
Marsh
MVP [MS Access]
>Your suggestion to use the On NotInList allowed me to add my own error
>message, but then the standard system message followed. I tried to turn this
[quoted text clipped - 9 lines]
>> > I'm trying to trap this error so I can use my own custom message, but no luck
>> > yet. How do I go about doing this?