Ver Mensaje Individual
  #10 (permalink)  
Antiguo 25/04/2010, 14:33
41b3r70
 
Fecha de Ingreso: febrero-2010
Mensajes: 28
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Filtrar un listbox por varios criterios

Hola. He probado a hacerlo como dice lokoman. No funciona me dice que la sentencia select tiene una sintaxis no valida. Os pongo el codigo que tengo, bueno una parte que es largo. Os pongo las dos primeras opciones y luego la busqueda en el recordset a ver si veis el fallo porque yo no he sido capaz.

If Chk_Orden.Value = 1 Then
If strSelect <> "" Then
strSelect = strSelect & " Orden = '" & Txt_Orden & "'"
Else
strSelect = strSelect & " and Orden = '" & Txt_Orden & "'"
End If
End If

If Chk_Fecha.Value = 1 Then
If strSelect <> "" Then
strSelect = strSelect & " FHInicio = '" & Txt_Fecha & "'"
Else
strSelect = strSelect & " and FHInicio = '" & Txt_Fecha & "'"
End If
End If

Dim clmAdd As ColumnHeader
Dim itmAdd As ListItem

Set rs = New ADODB.Recordset

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= C:\Documents _
and Settings\Alberto\Escritorio\Goitek_Logic.mdb"

rs.Source = "TablaAlberto"
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic

If rs.State = 0 Then
strCabecera = "Select * from TablaAlberto Where"
strSentencia = strCabecera & strSelect

rs.Open strSentencia, cn

End If




Y el error que me da:

Error '-2147217900 (80040e14)' en tiempo de ejecucion:
Error de sintaxis (falta operador) en la expresion de consulta 'and Orden='090044'

090044 es el numero de orden que busco.