Results 1 to 7 of 7
  1. #1
    stevie23 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    3

    Search function in acces

    hi All,



    I hope that someone can help me. I have a database in acces and also a Form. This consists of different part numbers on different identifcation level.

    1 part can have small different options and there the second level is c level which all go under the same D (level 1).

    Now i want to have a search funcion(query or form)build that i can just search 123456789 and that all forms which have this information in (in all columns) show in the results.


    ID DPART_PART_NO CPART_PART_NO DESCRIPTION FIN_SUB_BUSINESS_CODE Field1 Field2
    1 123456789 D 123456789 C B & P MEX 0 0
    2 123456789 D 987654321 C B & P MEX 0 0

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you need to build a filter to compare all fields with your text entry - perhaps in the click event to a button

    me.filter="dpart_part_no like '*" & me.txtsearch & "*' OR cpart_part_no like '*" & me.txtsearch & "*' OR ........
    me.filteron=true


    the above assumes you are entering a partial entry in your search field which could be anywhere in the field value and is the slowest method because indexing cannot be used. If you are entering a full entry then you can use

    me.filter="dpart_part_no ='" & me.txtsearch & "' OR cpart_part_no = '" & me.txtsearch & "' OR ........
    me.filteron=true

    which will use indexing

    or if users will know the beginning then this will be as fast as the indexed search

    me.filter="dpart_part_no like '" & me.txtsearch & "*' OR cpart_part_no like '" & me.txtsearch & "*' OR ........
    me.filteron=true

  3. #3
    stevie23 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    3
    is there somewhere like a guide where i can follow to build this filter?Thanks

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    your requirement is a common one so can't suggest a guide as such - only other threads suggesting the same as I have in my post - not quite sure what you don't understand

    Look to the bottom of this thread where others have asked the same question or google something like 'access vba create search form' or similar to find youtube videos and threads/suggestions on other sites

  5. #5
    stevie23 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    3
    thanks again for your help!

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    if you are trying to understand about and's and or's, think of them a bit like addition (for and's ) and multiplication (for or's) in a formula. All evaluations will evaluate to true or false i.e. dpart_part_no like '" & me.txtsearch & "*' will either be true or false, it can't be anything else. so sometimes you need to use brackets to get the required result

    so with a formula

    1+(3*5)=16

    (1+3)*5=20

    true can also be represented a x=1 and false as x=0

    so put that into your formula

    1=1 and (3=3 or 5=5) evaluates to true

    1=0 and (3=0 or 5=5) evaluates to false

    1=1 and (3=0 or 5=5) evaluates to true

    1=1 and (3=0 or 5=0) evaluates to false

    in your case your filter can be represented as

    (1=1) or (3=3) or (5=5) - if any evaluation returns true, the whole evaluation will be true

    if you used and's instead

    (1=1) and (3=3) and (5=5) - if any evaluation returns false, the whole evaluation will be false


    Not sure if this clarifies the theory for you

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

Similar Threads

  1. Search Function
    By sk88 in forum Access
    Replies: 2
    Last Post: 01-05-2012, 12:33 PM
  2. Problem with search function
    By sk88 in forum Access
    Replies: 2
    Last Post: 12-20-2011, 01:05 PM
  3. Replies: 1
    Last Post: 03-18-2010, 09:12 AM
  4. search function
    By Eric1066 in forum Access
    Replies: 0
    Last Post: 10-23-2009, 10:23 AM
  5. acces listbox hatası(acces debug)
    By carso in forum Access
    Replies: 1
    Last Post: 09-22-2009, 04:11 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