Bonsoir Forum
Bonsoir tout le monde
SVP Gentelmans
Comment corriger ce code de Command3 pour modification dans Listview..j'ai trop essaye mais malheureusement pas de resultat
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
52
53
54
55
56
57
58
59
60
61
62
63
Dim cn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Private Sub Form_Load()
cn.Provider = "Microsoft.Jet.OLEDB.4.0;"
cn.Open App.Path & "\MADALIST.mdb"
cn.CursorLocation = adUseClient
Lesinformations
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "ID"
ListView1.ColumnHeaders.Add , , "Name"
ListView1.ColumnHeaders.Add , , "Address"
ListView1.ColumnHeaders.Add , , "Phone"
End Sub
Private Sub ListView1_Click()
On Error GoTo Error:
Set rs1 = cn.Execute("WORKING")
While Not rs1.EOF
If ListView1.SelectedItem.Text = rs1!id Then
Text1 = rs1.Fields(0)
Text2 = rs1.Fields(1)
Text3 = rs1.Fields(2)
Text4 = rs1.Fields(3)
rs1.MoveLast
rs1.MoveNext
Else
rs1.MoveNext
End If
Wend
Error:
End Sub
Public Sub Lesinformations()
On Error GoTo Error:
ListView1.ListItems.Clear
Dim LST As ListItem
Set rs1 = cn.Execute("Select * from WORKING ")
If Not (rs1.BOF And rs1.EOF) Then
Do While Not rs1.EOF
Set LST = ListView1.ListItems.Add(, , rs1.Fields(0))
LST.SubItems(1) = rs1.Fields(0)
LST.SubItems(2) = rs1.Fields(1)
LST.SubItems(3) = rs1.Fields(2)
LST.SubItems(4) = rs1.Fields(3)
rs1.MoveNext
Loop
End If
Error:
End Sub
Private Sub Command3_Click()
On Error Resume Next
If Text1.Text = "0" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
MsgBox "ADD informations", vbCritical + vbExclamation + vbMsgBoxRtlReading, "Error": Exit Sub: End If
rs1.Open "SELECT * FROM WORKING where id=" & id & "", cn, 1, 3
With rs1
!id = Text1.Text
!Name = Text2.Text
!Adress = Text3.Text
!Phone = Text4.Text
.Update
End With
MsgBox " Succed  ", vbCritical + vbExclamation + vbMsgBoxRtlReading, "Finish Modification"
Text1 = "": Text2 = "": Text3 = "": Text4 = ""
Lesinformations
End Sub
Merci d'avance pour l'aide
Cordialement
MADA