Re: OnNotInList

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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
>
>


.



Relevant Pages

  • OnNotInList
    ... MsgBox "You must select a value from the list!", vbInformation, ... Private Sub Combo1_NotInList ... Function ValueNotInListResponse() As Long ...
    (microsoft.public.access.formscoding)
  • Re: OnNotInList
    ... > MsgBox "You must select a value from the list!", vbInformation, ... > Private Sub Combo1_NotInList ... > If invalid data is entered, the customized message pops up ...
    (microsoft.public.access.formscoding)
  • Re: Help Im stuck!
    ... Private Sub Form_Open ... MsgBox "THERE ARE NO RESULTS FOR YOUR SEARCH." ... , vbInformation, "No Records" ... Cancel = True ...
    (microsoft.public.access.formscoding)
  • Re: Class terminate wird nicht ausgeführt
    ... ' /// Code in Klassenmodul Class1 ... Private Sub Class_Initialize ... MsgBox "Class_Terminate", vbInformation ...
    (microsoft.public.de.vb)
  • Re: Validating a Field
    ... Private Sub Text0_BeforeUpdate ... Cancel = True ... MsgBox "The First Character of the Book Code Must Be a Letter" ...
    (microsoft.public.access.forms)