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:
Private Sub cmdSearchFaults_Click() Dim strDescription As String Dim strCriteria As String Dim strFilter As String Dim strQuote As String strQuote = Chr(34) ''' FaultDescription is a text field with 255 chr max length strDescription = Me.FaultDescription strCriteria = InputBox("Enter search word.") ''' search evaluates FaultDescription to see if it contains strCriteria ''' if so it returns the contents of fault description thus evaluating to true ''' if not it returns a zero lenth string "" evaluating to false ''' however it does not seem as though it evaluates the function for each record as the filter is applied strFilter = strQuote & "[FaultDescription] = " & "'" & Search(strDescription, strCriteria) & "'" & strQuote Me.Filter = strFilter Me.FilterOn = True End Sub Public Function Search(Text, Word) As String If InStr(1, Text, Word, 1) > 0 Then Search = Text Else: Search = "" End If End Function




Reply With Quote