Results 1 to 6 of 6
  1. #1
    alicevuap is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2016
    Posts
    8

    VBA code for search button in a form

    Hello!



    I created a split form based on a query, in order to perform a search from a table. I added an unbound text field where to introduce the keyword, and a button with on click event in Macro builder as follows:
    Click image for larger version. 

Name:	Untitled-1.jpg 
Views:	27 
Size:	50.8 KB 
ID:	23866


    The issue is that i would like to perform the search in more fields and the limited number of characters in the "where condition" does not allow me to add more than 3 fields.

    Could someone help with an VBA code equivalent to this one, in which i can write all the conditions? (as far as i know there are no character limits in VBA)

    Thank you!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    It would look like a wherecondition:

    http://www.baldyweb.com/wherecondition.htm

    but the repeating fields mean your table is not normalized:

    http://r937.com/relational.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    alicevuap is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2016
    Posts
    8
    My form looks like this:
    Click image for larger version. 

Name:	2.jpg 
Views:	22 
Size:	58.8 KB 
ID:	23874
    How can i write the code to generate the results in the bottom table and not in a new form?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Personally I'd change the recordsource, but the closest to what you're doing:

    Me.Filter = "Subject..."
    Me.FilterOn = True

    The filter string would look like the link.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    alicevuap is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2016
    Posts
    8
    Thank you! It worked!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 10-20-2014, 03:25 PM
  2. Replies: 5
    Last Post: 07-13-2012, 01:15 AM
  3. Replies: 13
    Last Post: 07-05-2012, 10:33 AM
  4. Replies: 12
    Last Post: 03-22-2012, 02:48 AM
  5. RunTime Error 3075, code for search button
    By jacie in forum Programming
    Replies: 1
    Last Post: 04-15-2011, 05:23 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