+ Reply to Thread
Results 1 to 8 of 8

Forcing a combobox selection validate against other data

  1. #1
    Registered User
    Join Date
    02-14-2007
    Posts
    9

    Forcing a combobox selection validate against other data

    Greetings. I am doing an app with a form that allows for a user to enter a maximum of 2 records. It has a combobox (comcbobox1) with 5 values that go in a Type field - a, b, c, d, e'). There are rules about whether certain values can be selected based on whether the other record value for Type. One example of a rule might be to not allow selection of 'a' if the other record has b, d, or e in the type.

    My plan is to use the event like below which I am using for other controls to ensure the proper data entry (numeric, date, etc.) which works fine on other controls.

    Please Login or Register  to view this content.
    A label will appear with the appropriate selection choices. But the ControlValidate function does not fire unless I tab away, or select one of the buttons. I don't want to let the user move off of the combobox until a valid selection is made. Most of the event do not allow the "ByVal Cancel..." arguments.
    How can I go about doing this?

  2. #2
    Forum Expert
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    2,385

    Re: Forcing a combobox selection validate against other data

    As you appear to know the valid choices before making a choice from the combobox, why not load the combobox with only the valid choices.
    torachan.

  3. #3
    Registered User
    Join Date
    02-14-2007
    Posts
    9

    Re: Forcing a combobox selection validate against other data

    torachan
    Thanks for the suggestion. I have considered that. But it is possible that I get into a scenario where an update to a record would require an update to the other record, putting the user in a situation where neither record could be updated without simultaneously updating the other record. At that point, in addition to he warning label, I have another userform that will appear with a Proceed and Cancel button. The Proceed would make the appropriate change to both records. A label in that userform would explain the exact changes could be made. I want the user to understand why certain choices are not acceptable and "approve" making a change to the other record. The Cancel button would allow them to make a different selection. If I have no other options, your suggestion would have to be the solution

  4. #4
    Forum Expert
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    2,385

    Re: Forcing a combobox selection validate against other data

    from your descriptions there appears a convoluted process going on.
    why not upload your workbook to enable us to give better guidance.
    also please update your profile with your version # of Excel and your location (e.g. US, Asia, UK) as solutions are tailored to suit.

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    02-14-2007
    Posts
    9

    Re: Forcing a combobox selection validate against other data

    torachan I really appreciate you being willing to review the workbook. Having not received any other replies, I decided to cross post it - which apparently was 6 minutes after your response.
    This forum would not allow me to post the link last night because I am apparently don't have enough reps. I want to follow forum rules, but also believe in full disclosure about cross posting.
    That post can be found by a browser search for "Capturing Combobox BeforeUpdate event to run another sub"

    A reply on that forum kind of confirmed that the BeforeUpdate event on a combobox - although it exists - may be "buggy". I concur. I have just validated that BeforeUpdate event on a combobox only gets executed on exit. If I am wrong, I will accept corrections. I have verified this with a simple msgbox.

    So I am not going to ask for your time to review the workbook. The workaround I am going to do is capture the change event (which does work), write the value to a hidden textbox where I can run the validation on a BeforeUpdate event.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    47,487

    Re: Forcing a combobox selection validate against other data

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  7. #7
    Registered User
    Join Date
    02-14-2007
    Posts
    9

    Re: Forcing a combobox selection validate against other data

    AliGW
    I do respect forum rules. And not to be disrespectful to you, but please read my response prior to your post. I tried to update with the cross-posting link, but your forum would not allow it with a message "You are not allowed to post any kinds of links, images or videos until you post a few times." . I did note that cross-post the best that I could and even mentioned that I believe that I had a workaround to my issue. The other forum had allowed me to provide the cross-posting link. Out of respect to both forums, I am providing any updates as to my research on both forums. What could I have done differently?

    Sorry, it's a little frustrating to be dinged on a rule you would not allow me to follow.

    Have a good day.

  8. #8
    Registered User
    Join Date
    02-14-2007
    Posts
    9

    Re: Forcing a combobox selection validate against other data

    Here is an update for future readers. I did some additional testing. This is what I found.

    BeforeUpdate event on a combobox definitely is not working similar to the same event on a textbox. A simple msgbox test in BeforeUpdate does not execute until the user exits the field. Furthermore, when you exit the combobox, the BeforeUpdate runs before any exit event code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Save data in same row of combobox selection
    By gajaburu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2014, 11:57 AM
  2. [SOLVED] vlookup data on combobox selection by formula
    By cfinch100 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-18-2014, 11:36 AM
  3. [SOLVED] fill combobox selection based on a selection from the first combobox
    By Monza in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-14-2013, 07:34 PM
  4. [SOLVED] New to Forms-Validate a ComboBox and do something if not valid
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2013, 08:05 PM
  5. Combobox Selection To Insert Data
    By Mooseman60 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-04-2010, 12:38 PM
  6. Forcing RowSource in ComboBox to increase
    By LiamPotter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2008, 05:18 AM
  7. [SOLVED] Validate Combobox entry
    By MBlake in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2005, 04:06 PM

Tags for this Thread

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