Prevent Combobox Duplicates

  • Re: Combobox Duplicates


    Don't put them in. Here's one way to load a combobox with the unique entries in dataRRay.

  • Re: Combobox Duplicates


    Okay, I dony understand. My combobox is setup with code below

    "To know the road ahead, ask those coming back.":fatwalk:

  • Re: Combobox Duplicates


    Ok, I have spent a great deal of time manipulating one of roy's database forms to make this work. however, for some reason it does not search correctly. it picks up the county right, but not the state.. i need it to search by state and county.. both being criteria. not just county. thanks for your help

  • Re: Combobox Duplicates


    Replace your ComboBox1.List line with a routine as mikerickson suggested to add only unique items to your combobox1. Out the 2nd Sub in a Module and use the first to set it up and call it. Notice how I made use of one means to set a range.


    This method is similar but makes it a bit more modular.

  • Re: Combobox Duplicates


    Thanks. I will do that.. Im trying to use .find to locate information based on the criteria from 2 combobox'es. i have made an attempt, but its not working. It only picks up data based on what is entered in comboxbox2. Can you help?




    **ComboBox worked like a charm. thanks.

    "To know the road ahead, ask those coming back.":fatwalk:

  • Re: Combobox Duplicates


    Might take a while to wrap my head around that one.


    Suggestions:
    1. Set rSearch as type Range, not Variant.
    2. Try searching by rSearch and within that loop, search by rSearch2. You will need 2 c's and may want to use fewer With()s.


    You could set a discontiguous Range by the found items in rSearch. You could then use the OffSet() method to get the Range for a 2nd find loop.


    Another method scribbled out for one comparison.
    e.g.

    Code
    If [A1]&[B1]=ComboBox1.text & ComboBox2.text then...


    The ... means to assign that row to a found range.

  • Re: Combobox Duplicates


    im sorry, but my skills are not developed enough to understand what you are saying. I have previously posted workbook examples, but i just need the segment below fixed? is that not possible, or am i goin to have to try another route?

    "To know the road ahead, ask those coming back.":fatwalk:

  • Re: Combobox Duplicates


    For (1), you have:

    Code
    Dim rSearch, rsearch2 As Range


    This is the same as:

    Code
    Dim rSearch as Variant, rsearch2 As Range


    I think you meant:

    Code
    Dim rSearch as Range, rsearch2 As Range


    Your find type strings are coded as above too. In other words, if you do not set an As type, the type is set as Variant.


    I will look into item (2), later tonight.

  • Re: Combobox Duplicates


    yea, im using on example roy put together on his site.. below is the code i am using.. i would like to add another combobox that i could use as search criteria.. basicly if combobox1 was found in col a2, then if combobox2 was found in b2 then its a match and all is good.. but now what it does when i add the combobox2 is just search for combobox2 disregarding combobox1.. anyhow.. here is the code im using with one combobox.. its very limited.. if someone would just show me how to use 2 that would be awesome. thanks.


    "To know the road ahead, ask those coming back.":fatwalk:

  • Re: Combobox Duplicates


    Try this:

  • Re: Prevent Combobox Duplicates


    ok, but you left off adding the information to the list box? how do i do that now?

    "To know the road ahead, ask those coming back.":fatwalk:

  • Re: Prevent Combobox Duplicates


    The suggestion worked as it limited the amount of options allowed in combobox2, but it still does not apply this criteria to the search.. its still on search via combobox1 and is not taking combobox2 into consideration? my question is how do i get the code i posted earlier to search by both combobox'es

    "To know the road ahead, ask those coming back.":fatwalk:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!