Results 1 to 4 of 4

Thread: Search capabillity

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Location
    Huntsville AL
    Posts
    2

    Search capabillity

    Here is my problem:

    I am trying to provide the ability to perform a search of records. The basic setup is as follows:

    MS Access 2003
    Visual Basic 6.3

    Form as single form : frmAcftEditor
    Subform as continuous form: subFaultViewer
    Search is initiated with cmdSearchFaults command button and is located on header of subFaultViewer

    Desired result is to enter search criteria and display all records containing criteria.

    Here is the code I am attempting, I have tried other variations as well with no success. I am fairly new to VBA and not well versed as of yet. Hope someone can help and thanks in advance!

    VB Code:
    1. Private Sub cmdSearchFaults_Click()
    2.  
    3. Dim strDescription As String
    4. Dim strCriteria As String
    5. Dim strFilter As String
    6. Dim strQuote As String
    7.  
    8. strQuote = Chr(34)
    9. ''' FaultDescription is a text field with 255 chr max length
    10. strDescription = Me.FaultDescription
    11. strCriteria = InputBox("Enter search word.")
    12. ''' search evaluates FaultDescription to see if it contains strCriteria
    13. ''' if so it returns the contents of fault description thus evaluating to true
    14. ''' if not it returns a zero lenth string "" evaluating to false
    15. ''' however it does not seem as though it evaluates the function for each record as the filter is applied
    16. strFilter = strQuote & "[FaultDescription] = " & "'" & Search(strDescription, strCriteria) & "'" & strQuote
    17.  
    18. Me.Filter = strFilter
    19. Me.FilterOn = True
    20.    
    21. End Sub
    22.  
    23.  
    24.  
    25. Public Function Search(Text, Word) As String
    26.  
    27. If InStr(1, Text, Word, 1) > 0 Then
    28.     Search = Text
    29. Else: Search = ""
    30. End If
    31.  
    32. End Function
    Last edited by si_the_geek; Feb 17th, 2006 at 10:45 AM. Reason: changed Code tags to VBCode

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width