multiple filter

javier_83

Registered User.
Local time
Today, 15:59
Joined
Jul 9, 2008
Messages
49
hi, i make a form, where i can see all the models i have on my database, so i can pick the one i need!!but i want to make a filter
i have several textbox so i can choose, what do i wan to make the filter i use a code, and make the filter but i cant use multiples filter, this make me use only one filter at timei use this code

Option Compare Database
Private Sub buscarnombre_AfterUpdate()
DoCmd.ApplyFilter "", "[Nombre] Like '" & Me.buscarnombre & "*'"
End Sub
Private Sub buscarnombre_Change()
On Error GoTo Err_Comando12_Click
DoCmd.ApplyFilter "", "[Nombre] Like '" & Me.buscarnombre & "*"
buscarnombre.SetFocus
buscarnombre.SelStart = Len(buscarnombre)
Exit_Comando12_Click:
Exit Sub
Err_Comando12_Click:
Resume Exit_Comando12_Click
End Sub
Private Sub buscarso_AfterUpdate()
DoCmd.ApplyFilter "", "[SO] Like '" & Me.buscarso & "*'"
End Sub
Private Sub buscarso_Change()
On Error GoTo Err_Comando12_Click
DoCmd.ApplyFilter "", "[SO] Like '" & Me.buscarso & "*"
buscarso.SetFocus
buscarso.SelStart = Len(buscarso)
Exit_Comando12_Click:
Exit Sub
Err_Comando12_Click:
Resume Exit_Comando12_Click
End Sub
Private Sub buscarsp_AfterUpdate()
DoCmd.ApplyFilter "", "[servpack] Like '" & Me.buscarsp & "*'"
End Sub
Private Sub buscarsp_Change()
On Error GoTo Err_Comando12_Click
DoCmd.ApplyFilter "", "[Servpack] Like '" & Me.buscarsp & "*"
buscarsp.SetFocus
buscarsp.SelStart = Len(buscarsp)
Exit_Comando12_Click:
Exit Sub
Err_Comando12_Click:
Resume Exit_Comando12_Click
End Sub
Private Sub Form_Current()
Me.Refresh
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Refresh
End Sub

what can i do, to amek a multiple filter?????'

thanks, and sorry for my english!!
 

Attachments

  • filtro.jpg
    filtro.jpg
    101.9 KB · Views: 140
Last edited:
i check and copy the code

and when i click i see this error

that the clic event doestn accept that events
 

Attachments

  • filtroerror.JPG
    filtroerror.JPG
    28.5 KB · Views: 133
i put my code like this

Option Compare Database
Private Sub Comando4_Click()
'Set the Dimensions of the Module
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()
'Constant Select statement for the RowSource
strSQL = "SELECT model.id_model, model.Nombre, model.SO, model.Servpack " & _
"FROM model"
strWhere = "WHERE"
strOrder = "ORDER BY model.id;"

'Set the WHERE clause for the Listbox RowSource if information has been entered into a field on the form
If Not IsNull(Me.buscarnombre) Then '<--If the textbox txtFName contains no data THEN do nothing
strWhere = strWhere & " (model.nombre) Like '*" & Me.buscarnombre & "*' AND" '<--otherwise, apply the LIKE statment to the QueryDef
End If
If Not IsNull(Me.buscarso) Then
strWhere = strWhere & " (model.SO) Like '*" & Me.buscarso & "*' AND"
End If
If Not IsNull(Me.buscarsp) Then
strWhere = strWhere & " (model.Servpack) Like '*" & Me.buscarsp & "*' AND"
End If

'Remove the last AND from the SQL statment
strWhere = Mid(strWhere, 1, Len(strWhere) - 5)
'Pass the SQL to the RowSource of the listbox
Me.Lista7.RowSource = strSQL & " " & strWhere & "" & strOrder
End Sub
 
How many spaces do you have between the *' AND?? There should be 2...
 
is there a way to continue working as i was doing, or its better in your form??
 
You should be able to adapt the code into your form. My Espanol is a little rusty...can you translate the error you are getting?
 
it said that the expression when i clic: which introduced as property values Event an error: the event or class does not support all events
 

Users who are viewing this thread

Back
Top Bottom