Bonjour à tous,
j'aimerai que lorsque je saisi un produit dans mon textbox que s'il y a au moins une occurence qui existe dans ma table produit, que toutes les occurences qui correspondent à ce que j'aurai s'affiche dans un flexgrid et que la 1ère occurrence vienne complété ce que j'aurai saisi. Puis enfin en dernier, que si je clique sur un produit que les informations de ce dernier s'affiche dans les textbox adéquats. Voici donc ce que j'ai fait:
- dans le Load de mon form(formvente) :
- dans le Change de mon textbox( txtproduit) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12connect Set rsClt = New ADODB.Recordset rsClt.CursorLocation = adUseClient rsClt.CursorType = adOpenStatic rsClt.LockType = adLockOptimistic rsClt.ActiveConnection = cn rsClt.Source = "select * from TableProduit order by (desproduit)" rsClt.Open rsClt.MoveFirst Set msfafficheprod.DataSource = rsClt
- dans le Click de mon flexgrid(msfafficherprod) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24connect Dim str As String If rsClt.State <> adStateClosed Then rsClt.Close str = "select distinct * from TableProduit where desproduit like '" & txtproduit & "%'order by desproduit" rsClt.Source = str rsClt.Open If Len(txtproduit.Text) >= 1 And rsClt.RecordCount >= 1 Then msfafficheprod.Visible = True For i = 2 To 19 msfafficheprod.BackColorSel = &H80C0FF Next msfafficheprod.RowSel = 1 End If If txtproduit.Text = "" Then msfafficheprod.Clear msfafficheprod.Visible = False ElseIf Len(txtproduit.Text) >= 1 Then msfafficheprod.Clear affiche_produit End If
- Voici ma procédure (affiche_produit), celle qui me permet d'afficher les occurences dans le flexgrid :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9Call connect txtnumproduit.Text = msfafficheprod.TextMatrix(msfafficheprod.Row, 0) txtproduit.Text = msfafficheprod.TextMatrix(msfafficheprod.Row, 1) txtqteprod.Text = msfafficheprod.TextMatrix(msfafficheprod.Row, 2) txtpuprod.Text = msfafficheprod.TextMatrix(msfafficheprod.Row, 3) msfafficheprod.Visible = False
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 Call connect Dim c As Integer connect titre = Array("Numéro", "Désignation", "Qté en stock", "Prix Unitaire") taille = Array(300, 2500, 2500, 1500) For i = 0 To 3 msfafficheprod.ColWidth(i) = taille(i) msfafficheprod.TextMatrix(0, i) = titre(i) Next If Len(txtproduit.Text) >= 1 And rsClt.RecordCount >= 1 Then Dim rs1 As New Recordset rs1.Open "select * from Tableproduit where desproduit like '" & txtproduit & "%' order by(desproduit) ", cn Dim rs3 As New ADODB.Recordset rs3.Open "select tablestock.qteenstock from tableproduit, tablestock where (tableproduit.numstock = tablestock.numstock) and desproduit like '" & txtproduit & "%' order by (desproduit)", cn, 1, 2 Dim rs4 As New ADODB.Recordset rs4.Open "select tabletarif.pvprod as test1 from tableproduit, tabletarif where (tableproduit.numtarif = tabletarif.numtarif) and desproduit like '" & txtproduit & "%' order by (desproduit)", cn, 1, 2 bb = (rs4!test1) i = 1 While (Not rs1.EOF) If Not IsNull(rs1) Then msfafficheprod.TextMatrix(i, 0) = rs1(0) msfafficheprod.TextMatrix(i, 1) = rs1(1) msfafficheprod.TextMatrix(i, 2) = rs3(0) msfafficheprod.TextMatrix(i, 3) = rs4(0) End If i = i + 1 rs1.MoveNext rs3.MoveNext rs4.MoveNext Wend msfafficheprod.Refresh rs1.Close rs3.Close rs4.Close cn.Close Else End If
Voilà. Maintenant les problème que j'ai sont que :
- je ne sais pas comment faire complété ce que j'aurai saisi par la première occurence trouvée ;
- bizarrement lorsque je clique sur une autre occurence que la 1ère que je veux dans mon flexgrid il ne me remplit pas les textbox adéquat (sinon ça marche pour la première).
Je sais bien que c'est beaucoup de choses à lire et à comprendre mais franchement je patoge grave. Je n'y comprends rien.
Merci d'avance.
Cordialement





Répondre avec citation
Partager