+ Reply to Thread
Results 1 to 10 of 10

Returning search from textbox and combobox conbined

  1. #1
    Forum Contributor
    Join Date
    11-23-2007
    Location
    Suffolk, UK
    Posts
    298

    Returning search from textbox and combobox conbined

    Afternoon,

    I have a list box that I can search for from either a TextBox or a ComboBox, but I want to do a multiple search with entries in both boxes and return the corresponding data from the data sheet, Textbox1114 looks at column B (date) and Combobox3 looks at column H (Haulier), so I need to return the data for a haulier on a certain date...

    Hopefully someone has a solution to my little problem, the code below runs the serach of the datarange and returns the search criteria but onlu based on the one text/combo box.

    Please Login or Register  to view this content.
    Thanks in advance for your help

    Reg
    Attached Files Attached Files
    Last edited by reggie1000; 11-01-2011 at 01:08 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Returning search from textbox and combobox conbined

    Here is what I came up with. You need to change the format of data in column B to "Date".

    Please Login or Register  to view this content.
    I tried to preserve as much of your code as possible, but it could be cleaned up a bit. You may want to look for ways to not jump around with GoTo as much.
    Attached Files Attached Files
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,647

    That's why they invented advancedfilter

    Cfr. the attachment
    Attached Files Attached Files



  4. #4
    Forum Contributor
    Join Date
    11-23-2007
    Location
    Suffolk, UK
    Posts
    298

    Re: Returning search from textbox and combobox conbined

    Hello,

    Thanks for the replies, I've tried both suggestions, DaveGugg's version freezes I think that its in a loop and SNB's suggestion doesn't work, it will list to the sheet but not into the listbox,

    Has anyone got any suggestions, I'm trying not to go down the route of concatenating the 2 cells as a helper cell as i think there is a more elegant solution.

    thanks reg

  5. #5
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Returning search from textbox and combobox conbined

    It worked on your sample workbook. Perhaps you could post a new workbook that demonstartes the "freeze".

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,647

    Re: Returning search from textbox and combobox conbined

    SNB's suggestion doesn't work, it will list to the sheet but not into the listbox,
    My suggestion works, but you don't.
    You may adapt my suggestion to populate the listbox.
    Can't be too complicated...(a one-liner)

  7. #7
    Forum Contributor
    Join Date
    11-23-2007
    Location
    Suffolk, UK
    Posts
    298

    Re: Returning search from textbox and combobox conbined

    Hi DaveGugg,

    I've attached a new version of the workbook, the previous one you amended had the same date for all of column B, I've put in three different dates and it freezes when the dates are different, if its just one date it works fine.

    thanks reg
    Attached Files Attached Files

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Returning search from textbox and combobox conbined

    It isn't working for haulier1 because you don't have any SHUNTERs called haulier1; they are called Haulier1. I would suggest populating combobox 3 with values in Data column H instead of hard typing them.

  9. #9
    Forum Contributor
    Join Date
    11-23-2007
    Location
    Suffolk, UK
    Posts
    298

    Re: Returning search from textbox and combobox conbined

    Thanks Davegugg,

    Thanks for showing what an idiot I've been, thanks again for all your help, much appreciated.

    ta reg

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,902

    Re: Returning search from textbox and combobox conbined

    Quote Originally Posted by snb View Post
    My suggestion works, but you don't.
    ...
    snb.... please watch it. We don't treat our visitors with that kind of disrespect here!
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ 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