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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
Private Sub Form_Initialize()
fichier = "marque.txt"
fichier2 = "materiel.txt"
Dim db As DAO.Database
Dim rs As DAO.Recordset
Me.combnom.Clear
'ouverture la plus simple en mode partagé
Set db = DAO.Workspaces(0).OpenDatabase(MA_BASE_ACCESS, False, False)
'Ouverture d'une requête sur la table, dbForwardOnly = lecture en avant = plus rapide
Set rs = db.OpenRecordset("select * from [coordonnees];", , dbForwardOnly)
'Tant qu'il en reste
Do While Not rs.EOF
'Ajout dans la combo
Me.combnom.AddItem rs.Fields(0).ValueICI LA LIGNE D'ORIGINE 1 CHAMPS
DES QUE JE REMPLACE LA LIGNE DU DESSUS PAR CELLE CI J'AI LE PROBLEME PLUS BAS
'Me.combnom.AddItem rs!nom & " " & rs!prenom
'passe au suivant
rs.MoveNext
Loop
'On affiche le premier élément de la liste comme sélectionné
If Me.combnom.ListCount > 0 Then
Me.combnom.ListIndex = 0
End If
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub Form_Load()
txtdate.Text = DateName(Date)
' ouverture de la connexion à la BDD avec la technique ADO activer ado 2.7
Set Cnx = New ADODB.Connection
Cnx.Provider = "Microsoft.Jet.Oledb.4.0"
Cnx.ConnectionString = App.Path & "\basesav.mdb"
Cnx.Open
Set str = fso.OpenTextFile(fichier)
Do While str.AtEndOfStream = False
combomarque.AddItem str.ReadLine
Loop
str.Close
Set str = fso.OpenTextFile(fichier2)
Do While str.AtEndOfStream = False
combotypemateriel.AddItem str.ReadLine
Loop
str.Close
End Sub
Private Sub Cmdajou_Click()
combomarque.AddItem txtajoutmarque.Text
Set strm = fso.OpenTextFile(fichier, ForAppending, True)
strm.WriteLine txtajoutmarque.Text
strm.Close
End Sub
Private Sub Cmdajoup_Click()
combotypemateriel.AddItem txtajoutperip.Text
Set strm = fso.OpenTextFile(fichier2, ForAppending, True)
strm.WriteLine txtajoutperip.Text
strm.Close
End Sub
Private Sub cmdajoutclient_Click()
Frm2.Hide
frmajoutclient.Show
frmajoutclient.WebBrowser1.Navigate App.Path & "\coordonnees.htm"
End Sub
Private Sub cmdok_Click()
LE PROBLEME ARRIVE ICI
frmdescriptionpanne.Show
Set corde = New ADODB.Recordset
corde.Open "coordonnees", Cnx, adOpenDynamic, adLockOptimistic
corde.Find "Nom=" & "'" & combnom.Text & "'"
frmdescriptionpanne.lblnom.Caption = corde!prenom & " " & combnom.Text
frmdescriptionpanne.lbltel.Caption = corde!telephone
frmdescriptionpanne.lbladresse.Caption = corde!adresse & ", " & corde!codepostal & ", " & corde!ville
corde.Close |
Partager