Consulting

Results 1 to 10 of 10

Thread: Solved: Search box

  1. #1
    VBAX Regular
    Joined
    Jan 2009
    Posts
    54
    Location

    Solved: Search box

    Hi all:

    Looking to make a form that will act as a search box. What my user needs is the ability to enter any one of 5 criteria and come back with the correct record/info.

    I picture this being a form with 5 unbound text boxes (for the 5 criteria) and an unbound list box for the results along with a SEARCH and CLEAR button.

    How would the code look? Is there any sample code anyone can provde?

    Thanks in advance.

    David
    David

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    David, see this as an Example of a fairly complex Search Form and Query.
    http://forums.techguy.org/business-a...ntities-3.html

    see post #33

  3. #3
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    You can also use the DLookup function to search a table for specified information via the WHERE condition. It only pulls a single record, so it's best to either have a complex WHERE condition to pull records based on multiple criteria, or search on the primary key, which your Users may not know.

    There are a lot of different ways to do this, but this should get you started.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  4. #4
    VBAX Regular
    Joined
    Jan 2009
    Posts
    54
    Location
    Randy:

    I only want one record so I will give it a try... thanks

    I really am looking to keep all the info to a form as it won't need to be printed as ODPs example shows.

    David
    David

  5. #5
    VBAX Regular
    Joined
    Jan 2009
    Posts
    54
    Location
    I tried to find code samples/examples for a DLookup function with multiple WHERE conditions.

    Can anyone assist with syntax?

    Thanks,
    David
    David

  6. #6
    VBAX Regular
    Joined
    Jan 2009
    Posts
    54
    Location
    Another thought - could I add a combo box that the user could choose what criteria they will be entering into the unbound textbox? Then the DLookup will search what is choosen... like:

    =DLookup("unboundtextcriteria","TableName","comboboxchoice")
    David

  7. #7
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    I am not sure that Dlookup is the best choice for what you are trying to do.
    If you want everything contained on one form then a Main/Subform setup where you set the Filter of the Subform is far more effiecient.
    You can also use the VBA Find to do something very similar, but it is less reliable.
    The attached database by Allen Browne is a very good Form Filter method.

  8. #8
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    This is an example of using the VBA Find function to do the searching, but as I sadi it is less reliable. I may have another version somewhere, that is slightly better.

  9. #9
    VBAX Regular
    Joined
    Jan 2009
    Posts
    54
    Location
    I like the Search 2000 version - how can I make the details section a list that comes up ONLY with search results? The way tis person has it I will potentially see thousands of records...

    Thanks
    David
    David

  10. #10
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    If you look at the VBA code for the Command button with the Filter sign on it you will see that each of the "filter" fields on the top section is added to the overall Form's filter. If you only have one filter field/combo then that makes the VBA cod equite simple.

Posting Permissions

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