Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

    Created Search Bar - pop out result in form List Box


    Hi,

    I created a search bar for user to enter the name they are searching for and
    I like it to pop out the result into another form in the List box.
    Could someone give some examples.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Perhaps:

    DoCmd.OpenForm "formname", , , "field=" & Me.listboxname
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    June, thanks for the example, but I am sorry I think you have it opposite.

    So this is what I have, a form with a search bar (text box name = tx22) and a button name cmd1.
    When user enter a name in the search bar, and click on button cmd1. It will open up form SRD
    and fill the list box name LB on the SRD form of what is searched, a query.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    Seems a bit cumbersome. What happens if the user is unsure of how to spell the name?
    Wouldn't a combo box with a dropdown that showed ALL the names to choose from work better?
    And what's the point of putting the name in a listbox?

    Perhaps an explanation of what the process is that you are attempting to solve would help.

  5. #5
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Ohh, because the list is big so a drop down wouldn't work as is too much to look at.
    The listbox is to show the wildcard search, so it could be 20 for example and at least a list box can accommodate a list of this size.

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    Either someone can jump in and post known working example code, or you could post your DB and we can work from that.

  7. #7
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    I'll post an example soon. Thx

  8. #8
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    This is my example.

    tb with a list of items,
    Query is the same in the form search button vba.
    the result should appear in form SRD list box. Thx
    Attached Files Attached Files

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    266 items is not very many. And since there are duplicates, the combobox list would actually be shorter with a RowSource of: SELECT DISTINCT List FROM tb;

    Make sure combobox AutoExpand is set to Yes. Combobox will match item in list as user types if item exists, otherwise if LimitToList set to No they can type whatever they want.


    What is purpose of the listbox?


    Odd list, words cut off.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    June,
    I was thinking the list may grow later as we add more. The example I provided are just examples they are not the real data.
    I got the list from the web, and I alter them is why they are cut off.

    I tried the combo box, combo box as I see it is just a drop down arrow that when click on shows all the items in your RowSource query.
    It allows user to type in it but only see the first one, closes match, that is on the list, not its related data or other similar matches even though the query (below)
    may show two (using wild card).

    Example below:
    The problem with the combo box is that the user has to know the first couple of letters of the word and then type example, a case I put on the bottom,
    App, only one of the App match will appear, Apple inc will show up and Apple.com and rating will not show up.

    For example there are two words
    Apple inc, 10 ratings
    Apple.com 15 ratings

    I think searching is better because I could do a while card search and both and all it's related data should come up.

    example query,
    SELECT name, rating
    FROM list
    WHERE name like "*ppl*"

    I use list is because there could potentially be more matches and so a list can show all the results.

  12. #12
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    See my post #21 here https://www.accessforums.net/showthr...t=69969&page=2

    I know this works because I use it without an issue. You can do full or partial searches and the list box populates with what you want so long as you did the leg work and typed out the fields and tables into it.

  13. #13
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    davgri,
    I looked at it, it didn't show the searches base on the users input but a query in the list box.

    So if user enters Axe, no result comes up. Thanks for the example

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Set combobox properties to display multiple columns in the dropdown.
    ColumnCount: 2
    ColumnWidths: 1";1"


    The combobox can be referenced in wildcard search.


    There really is no drawback to using combobox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    211
    You might want to take a look at my reference (post #21 https://www.accessforums.net/showthr...t=69969&page=2) my friend..... If a user typed Axe and it is anywhere in there then it will find it. I use it all the time doing partial (i.e. WILD CARD) searches (aka lazy person search). Just add all the criteria (tables and fieldnames) you want to be able to search for and add what June7 said to output it to this separate form you want. I can literally search for "M" and anything with an "M" displays.

    Just set the button to do what June7 said so it opens this form of yours (i.e. DoCmd.OpenForm "frmPopUpName") and place the example code I referenced (with as many tables and fields you want, just specify the table and fieldname like table.[fieldname] if referencing multiple tables) on your popup form VBA under On Load [Event Procedure], then set the .RowSource and .Requery for your list box on that form, then change Me!txtRecordSearchBox to the search box field where the button that opened this form was to [Forms]![ButtonFormName]!txtRecordSearchBox so it references whatever the user typed in order to search records for either an exact or partial match and return those results.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Search box that shows result in Form
    By revvedmoto in forum Programming
    Replies: 16
    Last Post: 02-20-2014, 03:20 PM
  2. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  3. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  4. Replies: 1
    Last Post: 06-09-2012, 05:44 PM
  5. Replies: 3
    Last Post: 11-07-2011, 10:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums