Ayuda con filtro

A ver, me surgió otro problema a ver si vos podes ayudarme:

Cuando probé los filtros en lugar de filtrar como debe, me dejaba el flex en blanco

Trate de poner el filtro que funcionaba y que te puse como ejemplo en la pregunta anterior y tampoco parece servir, lo que es ilógico porque mi db es la misma que antes

Lo único que parece servir es cambiar el '* & Text1.Text & *' (que sirve para filtrar partes de la palabra y no la palabra exacta) por el '" & Text1.Text & "' (que filtra la palabra exacta)

Te dejo el código completo a ver si encontrás algún fallo

 
Dim X AS Integer
Option Explicit
Private Sub Combo2_Click()
X = Combo2.ListIndex
Call cargastock
Data2.Refresh
flex1.Refresh
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Command1_Click()
Call filtrar
Data2.Refresh
flex1.Refresh
End Sub
Private Sub Command3_Click()
Form2.Hide
Form1.Show
End Sub
Private Sub Form_Load()
X = 0
'INICIO DE CONTROLES PARA COMBO BOX
Data1.ReadOnly = True
Dim Path_Base_Dato As String, db As Database
Dim rst As Recordset
 Path_Base_Dato = App.Path
 Path_Base_Dato = Path_Base_Dato & \base.mdb 
 'Abre la base de datos
 Set db = OpenDatabase(Path_Base_Dato)
 'Abre el Recordset con la consulta: Selecciona los nombres ordenados
 Set rst = db.OpenRecordset( _
 SELECT NOMBRES FROM VENDEDORES ORDER BY NOMBRES , _
 dbOpenSnapshot)
 ' Se mueve al primer registro
 rst.MoveFirst
 Do While Not rst.EOF
 'Agrega el Nombre al Combo
 Combo2.AddItem rst!NOMBRES
 'siguiente registro
 rst.MoveNext
 Loop
 'Cierra el recordset y la base
 rst.Close
 db.Close
 'Se asigna la base de datos al Data1
 Data1.DatabaseName = Path_Base_Dato
 'Seleccionamos el primer elemento del combo
 Combo1.ListIndex = 0
'FIN DE CONTROLES PARA COMBO BOX'
End Sub
Private Sub cargastock()
Select Case X
Case 0
Data2.RecordSource = Select * FROM STOCK00 WHERE Stock <> '0' 
Case 1
Data2.RecordSource = Select * FROM STOCK01 WHERE Stock <> '0' 
Case 2
Data2.RecordSource = Select * FROM STOCK02 WHERE Stock <> '0' 
Case 3
Data2.RecordSource = Select * FROM STOCK03 WHERE Stock <> '0' 
Case 4
Data2.RecordSource = Select * FROM STOCK04 WHERE Stock <> '0' 
Case 5
Data2.RecordSource = Select * FROM STOCK05 WHERE Stock <> '0' 
Case 6
Data2.RecordSource = Select * FROM STOCK06 WHERE Stock <> '0' 
Case 7
Data2.RecordSource = Select * FROM STOCK07 WHERE Stock <> '0' 
Case 8
Data2.RecordSource = Select * FROM STOCK08 WHERE Stock <> '0' 
Case 9
Data2.RecordSource = Select * FROM STOCK09 WHERE Stock <> '0' 
Case 10
Data2.RecordSource = Select * FROM STOCK10 WHERE Stock <> '0' 
Case 11
Data2.RecordSource = Select * FROM STOCK11 WHERE Stock <> '0' 
Case 12
Data2.RecordSource = Select * FROM STOCK12 WHERE Stock <> '0' 
Case 13
Data2.RecordSource = Select * FROM STOCK13 WHERE Stock <> '0' 
Case 14
Data2.RecordSource = Select * FROM STOCK14 WHERE Stock <> '0' 
Case 15
Data2.RecordSource = Select * FROM STOCK15 WHERE Stock <> '0' 
Case 16
Data2.RecordSource = Select * FROM STOCK16 WHERE Stock <> '0' 
Case 17
Data2.RecordSource = Select * FROM STOCK17 WHERE Stock <> '0' 
Case 18
Data2.RecordSource = Select * FROM STOCK18 WHERE Stock <> '0' 
Case 19
Data2.RecordSource = Select * FROM STOCK19 WHERE Stock <> '0' 
Case 20
Data2.RecordSource = Select * FROM STOCK20 WHERE Stock <> '0' 
Case 21
Data2.RecordSource = Select * FROM STOCK21 WHERE Stock <> '0' 
Case 22
Data2.RecordSource = Select * FROM STOCK22 WHERE Stock <> '0' 
Case 23
Data2.RecordSource = Select * FROM STOCK23 WHERE Stock <> '0' 
Case 24
Data2.RecordSource = Select * FROM STOCK24 WHERE Stock <> '0' 
Case 25
Data2.RecordSource = Select * FROM STOCK25 WHERE Stock <> '0' 
Case 26
Data2.RecordSource = Select * FROM STOCK26 WHERE Stock <> '0' 
Case 27
Data2.RecordSource = Select * FROM STOCK27 WHERE Stock <> '0' 
Case 28
Data2.RecordSource = Select * FROM STOCK28 WHERE Stock <> '0' 
Case 29
Data2.RecordSource = Select * FROM STOCK29 WHERE Stock <> '0' 
Case 30
Data2.RecordSource = Select * FROM STOCK30 WHERE Stock <> '0' 
Case 31
Data2.RecordSource = Select * FROM STOCK31 WHERE Stock <> '0' 
Case 32
Data2.RecordSource = Select * FROM STOCK32 WHERE Stock <> '0' 
Case 33
Data2.RecordSource = Select * FROM STOCK33 WHERE Stock <> '0' 
Case 34
Data2.RecordSource = Select * FROM STOCK34 WHERE Stock <> '0' 
Case 35
Data2.RecordSource = Select * FROM STOCK35 WHERE Stock <> '0' 
Case 36
Data2.RecordSource = Select * FROM STOCK36 WHERE Stock <> '0' 
Case 37
Data2.RecordSource = Select * FROM STOCK37 WHERE Stock <> '0' 
Case 38
Data2.RecordSource = Select * FROM STOCK38 WHERE Stock <> '0' 
Case 39
Data2.RecordSource = Select * FROM STOCK39 WHERE Stock <> '0' 
Case 40
Data2.RecordSource = Select * FROM STOCK40 WHERE Stock <> '0' 
Case 41
Data2.RecordSource = Select * FROM STOCK41 WHERE Stock <> '0' 
Case 42
Data2.RecordSource = Select * FROM STOCK42 WHERE Stock <> '0' 
Case 43
Data2.RecordSource = Select * FROM STOCK43 WHERE Stock <> '0' 
Case 44
Data2.RecordSource = Select * FROM STOCK44 WHERE Stock <> '0' 
Case 45
Data2.RecordSource = Select * FROM STOCK45 WHERE Stock <> '0' 
Case 46
Data2.RecordSource = Select * FROM STOCK46 WHERE Stock <> '0' 
Case 47
Data2.RecordSource = Select * FROM STOCK47 WHERE Stock <> '0' 
Case 48
Data2.RecordSource = Select * FROM STOCK48 WHERE Stock <> '0' 
Case 49
Data2.RecordSource = Select * FROM STOCK49 WHERE Stock <> '0' 
Case 50
Data2.RecordSource = Select * FROM STOCK50 WHERE Stock <> '0' 
Case 51
Data2.RecordSource = Select * FROM STOCK51 WHERE Stock <> '0' 
Case 52
Data2.RecordSource = Select * FROM STOCK52 WHERE Stock <> '0' 
End Select
End Sub
Private Sub filtrar()
Data2.RecordSource = Select * FROM STOCK00 WHERE Producto LIKE '* & Text1.Text & *' 
End Sub

Dicho sea de paso, ya confirme varias veces que este filtrando el campo correcto y que lo que estoy filtrando aparece en ese campo

Gracias de antemano

1 Respuesta

Respuesta
1

Donde se encuentran los case las sentencias sql son incorrectas

Al final la sentencia la tienes <> '0' primero que todo cuando es numero o meneda no utilizamos la comilla simple intenta colocando como te dije anteriormente

Data2.RecordSource = Select * FROM STOCK51 WHERE Stock > 0

O también como tu estas colocando <> 0 eso también te podría servir

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas