Search form adapted from gromit is not working

sandy6078

Take a deep breath
Local time
Today, 03:19
Joined
Jul 17, 2007
Messages
135
I adapted the seach form example that I found here by Gromit for the database I am working on. When I open the form I get the following error.
A problem occurred while Microsoft Office Access was communicating with the OLE server or ActiveX Control.

I checked for missing references, misspelling and anything else that I can think of. Your help would be greatly appreciated.
 
Any suggestions would be greatly appreciated. Attached is the code I am using.
Code:
Private Sub btnClear_Click()
        
    ' Clear all search items
    Me.txtNo = ""
    Me.txtOpenEnd = ""
    Me.txtOpenStart = ""
    Me.cboCustomer = 0
    Me.cboDivNo = 0
    Me.cboProcess = 0
    Me.cboStatus = 0
       
End Sub

Private Sub btnSearch_Click()
    
    ' Update the record source
    Me.fSearchSubform.Form.RecordSource = "SELECT * FROM qSearch " & BuildFilter
    
    ' Requery the subform
    Me.fSearchSubform.Requery

End Sub


Private Sub Form_Load()
    
    ' Clear the search form
    btnClear_Click
    
End Sub

Private Function BuildFilter() As Variant
    Dim varWhere As Variant
    Dim varItem As Variant
    Dim intIndex As Integer

    varWhere = Null  ' Main filter
       
    ' Check for LIKE 8D Number
    If Me.txtNo > "" Then
        varWhere = varWhere & "[8DNumber] LIKE """ & Me.txtNo & "*"" AND "
    End If
    
    'Check for Open Date
   If Me.txtOpenStart > "" And Me.txtOpenEnd > "" Then
      varWhere = varWhere & "[DateOpened] BETWEEN #" _
      & Me.txtOpenStart & "# AND #" & Me.txtOpenEnd & "# AND "
   End If
    
    ' Check for StatusID
    If Me.cboStatus > 0 Then
        varWhere = varWhere & "[StatusID] = " & Me.cboStatus & " AND "
    End If
    
    ' Check for DivisionID
    If Me.cboDivNo > 0 Then
        varWhere = varWhere & "[DivID] = " & Me.cboDivNo & " AND "
    End If
    
    ' Check for ProcessID
    If Me.cboProcess > 0 Then
        varWhere = varWhere & "[ProcessID] = " & Me.cboProcess & " AND "
    End If
    
    'Check for CustomerID
   If Me.cboCustomer > 0 Then
      varWhere = varWhere & "[CustomerID] " & Me.cboCustomer & " AND "
   End If

   ' Check if there is a filter to return...
      If IsNull(varWhere) Then
           varWhere = ""
  
   Else
        varWhere = "WHERE " & varWhere
        
        ' strip off last "AND" in the filter
        If Right(varWhere, 5) = " AND " Then
            varWhere = Left(varWhere, Len(varWhere) - 5)
        End If
    End If
    
    BuildFilter = varWhere
    
End Function
 

Users who are viewing this thread

Back
Top Bottom