manix
Registered User.
- Local time
- Today, 06:37
- Joined
- Nov 29, 2006
- Messages
- 100
Hi All,
First off just let me thank gromit for posting the search form example in the sample database forum. I have used this to try and create my own little search form so I can query a table of data.
But I keep getting the run time error 3131. There is an issue with my FROM clause. I am using the following code:
	
	
	
		
Can anyone see where things might be going wrong?
As always, thanks to anyone who can help!
 First off just let me thank gromit for posting the search form example in the sample database forum. I have used this to try and create my own little search form so I can query a table of data.
But I keep getting the run time error 3131. There is an issue with my FROM clause. I am using the following code:
		Code:
	
	
	Private Sub btnSearch_Click()
    
    ' Update the record source
    Me.frmsubToolData.Form.RecordSource = "SELECT * FROM qryTooldata2 " & BuildFilter
    
    ' Requery the subform
    Me.frmsubToolData.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 ST Number
    If Me.cmbSTno > "" Then
        varWhere = varWhere & "[ST Order Number] = " & Me.cmbSTno & " AND "
    End If
    
    ' Check for Project Number
    If Me.TextProject > 0 Then
        varWhere = varWhere & "[Related to Project Number] = " & Me.TextProject & " AND "
    End If
    
    ' Check for Tool Status
    If Me.cmbstatus > "" Then
        varWhere = varWhere & "[Tool Status] = " & Me.cmbstatus & " AND "
    End If
    
    ' Check for Tool Type
    If Me.cmbtype > 0 Then
        varWhere = varWhere & "[Tool Type] = " & Me.cmbtype & " AND "
    End If
    
    ' Check for Tool Location
    If Me.cmblocation > 0 Then
        varWhere = varWhere & "[Tool Location] = " & Me.cmblocation & " AND "
    End If
    
    ' Check for LIKE Country
    If Me.Textcountry > "" Then
        varWhere = varWhere & "[FirstName] LIKE """ & Me.Textcountry & "*"" AND "
    End If
    
    BuildFilter = varWhere
    
End FunctionCan anyone see where things might be going wrong?
As always, thanks to anyone who can help!

 
	 
 
		 
 
		
 
  
 
		 
 
		