+ Reply to Thread
Results 1 to 5 of 5

Use VBA code to display message if combobox selection not in list

Hybrid View

  1. #1
    hurlbut777
    Guest

    Use VBA code to display message if combobox selection not in list

    When using combo box to display drop-down list, users can actually type in
    any value they want...not good for what I need. A feasible fix for this is
    to verify that the value typed in the combo box is in a list...if it isn't
    display a message that says Try Again.

    Based on the list below, what would the VBA code look like that says if
    combo box value is not in list then give error message?

    List: Monday, Tuesday, Wednesday

  2. #2
    Dave Peterson
    Guest

    Re: Use VBA code to display message if combobox selection not in list

    Change the style of the combobox to fmStyleDropdownList (2).

    hurlbut777 wrote:
    >
    > When using combo box to display drop-down list, users can actually type in
    > any value they want...not good for what I need. A feasible fix for this is
    > to verify that the value typed in the combo box is in a list...if it isn't
    > display a message that says Try Again.
    >
    > Based on the list below, what would the VBA code look like that says if
    > combo box value is not in list then give error message?
    >
    > List: Monday, Tuesday, Wednesday


    --

    Dave Peterson

  3. #3
    hurlbut777
    Guest

    Re: Use VBA code to display message if combobox selection not in l

    Other than converting the combobox to the form style...any help on the code
    below?

    Thanks

    "Dave Peterson" wrote:

    > Change the style of the combobox to fmStyleDropdownList (2).
    >
    > hurlbut777 wrote:
    > >
    > > When using combo box to display drop-down list, users can actually type in
    > > any value they want...not good for what I need. A feasible fix for this is
    > > to verify that the value typed in the combo box is in a list...if it isn't
    > > display a message that says Try Again.
    > >
    > > Based on the list below, what would the VBA code look like that says if
    > > combo box value is not in list then give error message?
    > >
    > > List: Monday, Tuesday, Wednesday

    >
    > --
    >
    > Dave Peterson
    >


  4. #4
    Registered User
    Join Date
    12-12-2005
    Posts
    8
    Hi,

    It won''t convert the combobox. Just change its behavior.

    But anyway, can use MatchRequired and then If MatchFound on change event.

    TJ

  5. #5
    Dave Peterson
    Guest

    Re: Use VBA code to display message if combobox selection not in l

    dim myArr as Variant
    myArr = array("Monday","Tuesday","Wednesday")

    if iserror(application.match(me.combobox1.value,myarr,0)) then
    'not a match, the board goes back
    else
    'do what you want
    end if

    But changing the .style is too easy to ignore.

    hurlbut777 wrote:
    >
    > Other than converting the combobox to the form style...any help on the code
    > below?
    >
    > Thanks
    >
    > "Dave Peterson" wrote:
    >
    > > Change the style of the combobox to fmStyleDropdownList (2).
    > >
    > > hurlbut777 wrote:
    > > >
    > > > When using combo box to display drop-down list, users can actually type in
    > > > any value they want...not good for what I need. A feasible fix for this is
    > > > to verify that the value typed in the combo box is in a list...if it isn't
    > > > display a message that says Try Again.
    > > >
    > > > Based on the list below, what would the VBA code look like that says if
    > > > combo box value is not in list then give error message?
    > > >
    > > > List: Monday, Tuesday, Wednesday

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1