Results 1 to 3 of 3
  1. #1
    lccrews is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Location
    Los Angeles
    Posts
    194

    Unhappy How do I create a search that yields results from a table.

    I have no idea what I'm doing. I have a table with formulas for supplements. Field1 has the end item, field2 has the ingredient. I want to create a search box that, when I type in a value, searches field2 and returns the different items in field1 that it is associated.
    Field 1 Field2
    Magnesium 110021
    Magnesium 110054
    Magnesium 110288
    Magnesium 110283
    Vitamin C 110021
    Search: 110021 Result 1: Used In: Magnesium, Vitamin C

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    1. create a continuous form with a recordsource of 'myTable' (whatever you have called your table) to display the results you want
    2. in the header section create an unbound text box control called say txtSearch
    3. in the header section create a button called say btnFind
    4. in the click event of btnFind put the following code - change Field2 to whatever you are calling it in the table.

    me.filter="[Field2] =" & txtSearch
    'if Field2 is a text field and not a numeric field then use this instead
    'me.filter="[Field2] ='" & txtSearch & "'"
    me.filteron=true

    5. open the form and type 110021 in your txtSearch control
    6. click the button. Your form should refresh to just show the ingredients associated with 110021

  3. #3
    lccrews is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Aug 2017
    Location
    Los Angeles
    Posts
    194
    Thank you for the help Ajax!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-30-2017, 08:22 AM
  2. Replies: 2
    Last Post: 08-23-2016, 11:58 AM
  3. Replies: 2
    Last Post: 07-19-2014, 01:58 PM
  4. Replies: 7
    Last Post: 09-21-2012, 03:30 PM
  5. Replies: 1
    Last Post: 10-24-2010, 04:01 PM

Tags for this Thread

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