Results 1 to 2 of 2
  1. #1
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199

    Universal Search

    I am working on universal search as the code :

    Code:
    Dim sFind As String
            Dim sField As String
        Dim sFilter As String
        
        If bFindLastKeySpace Then
           Search.Value = Search.Value & " "
          Search.SelStart = Len(sFind) + 2
        Else
            Search.SelStart = Len(sFind) + 1
        End If
    
        Search.SetFocus
        sFind = Nz(Search.Text, "")
        If Len(sFind) > 0 Then
            Dim iField, iFieldsIncluded As Integer
            iFieldsIncluded = 0
            sFilter = ""
            For iField = 0 To iFields - 1
                Select Case rsMe.Fields(iField).Type
                Case dbBoolean    'Field types not to search in
                    'Don't include it
                Case Else
                    sField = rsMe.Fields(iField).Name
                   If iFieldsIncluded > 0 Then sFilter = sFilter & " Or "
                        sFilter = sFilter & "[" & sField & "] Like '*" & sFind & "*'"
                        iFieldsIncluded = iFieldsIncluded + 1
                   End Select
            Next iField
    ****            Me.Filter = sFilter
            Me.FilterOn = True
        Else
            Me.Filter = ""
            Me.FilterOn = False
        End If
            Search.SetFocus
    'Search.SelLength = 0
        bFindLastKeySpace = False
    When i am trying to search "Man hood" Its giving error on ** marked line , "Error 2176, The setting of property is too long", Please Help?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You have it in a loop.. (sFilter = sFilter & "[" & sField)
    It's possible you keep adding on , and on, thus making the filter string too large. (char length)

    You shouldnt need that many key words.

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

Similar Threads

  1. Modified Universal Search
    By orange in forum Code Repository
    Replies: 4
    Last Post: 02-08-2017, 02:14 PM
  2. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  3. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  4. Replies: 5
    Last Post: 07-13-2012, 01:15 AM
  5. Universal Search
    By Douglasrac in forum Access
    Replies: 3
    Last Post: 05-20-2011, 06:25 PM

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