Results 1 to 9 of 9
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    Search on Split-Form

    I have a split-form where I am attempting to set up a search. I currently have the search set up to search the SSN field, the FirstName field, and the LastName field... Unfortunately there is a limit to how long this string can be. Is there a way to set up a combo for First Name and Last Name... so if someone searches for Joe Blow it will fine the one that matches both fields, but if they only search for Blow it will search for just that name in either field? I would also like a way to search for first letter of last name and last 4 of ssn, so A1234 if possible. Current code below:





    Code:
    [SSN] Like "*" & Replace([Forms]![frmRecordsSearch]![SearchFieldTxt],"-","") & "*" Or [LastName] Like "*" & [Forms]![frmRecordsSearch]![SearchFieldTxt] & "*" Or [FirstName] Like "*" & [Forms]![frmRecordsSearch]![SearchFieldTxt] & "*"

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Unfortunately there is a limit to how long this string can be.
    use shorter table and field names but what you are saying doesn't make sense - a string can be some 65k characters long and in terms of individual fields in a query grid you have only one criteria per field so you are not hitting the query grid limits or around 1064 chars per field.

    so if someone searches for Joe Blow
    are they likely to search using 'oe low'? if not then remove the initial * - most user know what names start with anyway.

    How are you applying your search? in a query as a recordsource to a form or applying a filter on a form? - what code are you using?. Need to know before looking at your requirement because your error does not make sense and needs to be resolved or at least understood otherwise could waste lots of times making suggestions which don't work due to an underlying problem.

  3. #3
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    I would say they should know the name accurately. It is currently set up as a filter on a form. It is through the builder which is why it is limiting to 255 characters I believe.

    When I search foe Joe it will pull the Joes up, when I search for Blow it will pull the Blows up, but when I search for Joe Blow it pulls nothing up... just not sure how to get it to look in both fields and to try and match both fields to one of the words typed.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you need another 'or' in your filter

    ....or [Forms]![frmRecordsSearch]![SearchFieldTxt]=[firstname] & " " & [lastname]

    however this may not be the right answer because you haven't answered my questions

    How are you applying your search? in a query as a recordsource to a form or applying a filter on a form? - what code are you using?.

  5. #5
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    It is a filter on the form, using the code originally posted. An ApplyFilter with:
    Code:
    [SSN] Like "*" & Replace([Forms]![frmRecordsSearch]![SearchFieldTxt],"-","") & "*" Or [LastName] Like "*" & [Forms]![frmRecordsSearch]![SearchFieldTxt] & "*" Or [FirstName] Like "*" & [Forms]![frmRecordsSearch]![SearchFieldTxt] & "*"

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    using the code originally posted. An ApplyFilter
    but you said Unfortunately there is a limit to how long this string can be. Are you saying this is not an issue any more? if so just add the code I provided to the end of your string.

  7. #7
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,474
    Can you not just right click in the field on the form and use the search filters there?

  8. #8
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80
    I was actually able to get this to work simply by making a calculated field including the FirstName and LastName fields in to one. thanks for the above ideas as they led me there

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I was actually able to get this to work simply by making a calculated field including the FirstName and LastName fields in to one
    As suggesting in post #4?

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

Similar Threads

  1. Replies: 10
    Last Post: 09-08-2016, 08:09 PM
  2. Replies: 3
    Last Post: 11-03-2015, 11:19 PM
  3. Replies: 1
    Last Post: 04-09-2015, 05:13 PM
  4. Replies: 3
    Last Post: 04-12-2014, 01:17 PM
  5. Replies: 10
    Last Post: 03-28-2011, 08:57 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