Re: OnNotInList
- From: "Al Camp" <anon@xxxxxxxx>
- Date: Tue, 10 May 2005 22:26:49 -0400
Tom,
Add this to the form module...
Private Function NotInListWarning()
MsgBox "You must select a value from the list!", vbInformation,
"Information"
End Function
In the NotInList property of each combo box call the function...
=NotInListWarning()
Tip: You can select all 100 combos at one time, and enter that function call
into all 100 at one time.
hth
Al Camp
"Tom" <anynomys@xxxxxxxxxxxxx> wrote in message
news:uvu177ZVFHA.3108@xxxxxxxxxxxxxxxxxxxxxxx
> On a form, I have 100+ combo boxes. To make sure that members not enter
> additional data (beyond the options of the combo list), I set the combo's
> property "Limit to List" = Yes.
>
> Then, if a user attempts to type in an non-valid value, I'd like to throw
> a
> customized message such as:
>
> MsgBox "You must select a value from the list!", vbInformation,
> "Information"
>
>
> However, I don't want to include the same 3 lines 100+ times (one for each
> combo box) into my VBA code... as illustrated below:
>
> &&&&&&&&&&&&&&&&&&&&&&&&&
>
> Private Sub Combo1_NotInList(NewData As String, Response As Integer)
> MsgBox "You must select a value from the list!", vbInformation,
> "Information"
> End Sub
>
>
> Private Sub Combo2_NotInList(NewData As String, Response As Integer)
> MsgBox "You must select a value from the list!", vbInformation,
> "Information"
> End Sub
>
> etc.
> etc.
> etc.
>
> Private Sub Combo100_NotInList(NewData As String, Response As Integer)
> MsgBox "You must select a value from the list!", vbInformation,
> "Information"
> End Sub
>
> &&&&&&&&&&&&&&&&&&&&&&&&&
>
>
>
> Instead, I'd rather have the MsgBox once and just call the same function
> from each combo box if invalid data is entered. I did this via the
> following method...
>
>
> &&&&&&&&&&&&&&&&&&&&&&&&&
>
> Function ValueNotInListResponse() As Long
>
> MsgBox "You must select a value from the list!", vbInformation,
> "Information"
>
> ValueNotInListResponse = acDataErrContinue
>
> End Function
>
> &&&&&&&&&&&&&&&&&&&&&&&&&
>
>
> Then, in each combo's "On Not In List" event, I added the following:
> =ValueNotInListResponse()
>
> Here's what works:
> If invalid data is entered, the customized message pops up
>
> Here's what I need some help with:
> After I get the customized message, Access still pops up the default
> message:
> "The text you entered isn't an item in the list..."
>
> My question: How can I get rid of the 2nd message "The text you
> entered..."?
> The additional line "ValueNotInListResponse = acDataErrContinue" doesn't
> seem to work for this.
>
>
> Thanks,
> Tom
>
>
.
- Follow-Ups:
- Re: OnNotInList
- From: Tom
- Re: OnNotInList
- References:
- OnNotInList
- From: Tom
- OnNotInList
- Prev by Date: Re: Brain teaser -- "Passing data from an unbound text in one form to another textbox in another form"
- Next by Date: Re: Match the values with table contents
- Previous by thread: OnNotInList
- Next by thread: Re: OnNotInList
- Index(es):
Relevant Pages
|