Public Function Import_CSV_File()
Dim FileNum As Integer
Dim InputFile As String
Dim InputString As String
Dim veld1, veld2, veld3, veld4, veld5, veld6, veld7, veld8, veld9, veld10 As String
Dim i As Integer
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim DataVal() As String
strSQL = "Select * From tvd"
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
FileNum = FreeFile()
InputFile = "C:\Temp\tvd.csv" '<-- Change to your folder and path
Open InputFile For Input Access Read Shared As #FileNum
'Line Input #FileNum, InputString '<--- To throw away the header line
Do Until EOF(FileNum) = True
Input #FileNum, veld1, veld2, veld3, veld4, veld5, veld6, veld7, veld8, veld9, veld10 'Read the data in
With rst
.AddNew
!veld1 = veld1
!veld2 = veld2
!veld3 = veld3
!veld4 = veld4
!veld5 = veld5
!veld6 = veld6
!veld7 = veld7
!veld8 = veld8
!veld9 = veld9
!veld10 = veld10
.Update
End With
Loop
Close #FileNum
End Function
|