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
| Private Sub ImportCSV_Click()
Dim Ligne As String
Dim Str_Nom As String
Dim Str_Prenom As String
Dim Date_DateNaissance As Date
Dim Str_Division As String
Dim Int_Numero As Double
Dim Int_NotesID As Integer
Dim db As DAO.Database: Set db = CurrentDb
Dim rsEleves As DAO.Recordset: Set rsEleves = db.OpenRecordset("tblEleves")
Dim rsNotes As DAO.Recordset: Set rsNotes = db.OpenRecordset("tblNotes")
Dim Int_NumFic As Integer
Dim Str_Champs() As String
Int_NumFic = FreeFile
Open "c:\liste.csv" For Input As #Int_NumFic
Line Input #Int_NumFic, Ligne ' pour eviter la premiere ligne
Int_Numero = 20120001
While Not EOF(1)
Line Input #1, Ligne
Str_Champs = Split(Ligne, ";")
Str_Nom = Str_Champs(0)
Str_Prenom = Str_Champs(1)
Date_DateNaissance = Str_Champs(2)
Str_Division = Str_Champs(3)
With rsNotes
.AddNew
![EC_Francais] = Null
![EC_Maths] = Null
.Update
With rsEleves
.AddNew
![Nom] = Str_Nom
![Prenom] = Str_Prenom
![Date-Naissance] = Date_DateNaissance
![Division] = Str_Division
![Numero-candidat] = Int_Numero
![notesID] = rsNotes.Fields("notesID")
.Update
Int_Numero = Int_Numero + 1
End With
End With
Wend
Close #Int_NumFic
End Sub |
Partager