Hello
I'm trying to upload a csv file into an Array then add records to a table.
I have the following code which gets the information from a csv file which works fine.
Problems:
1. When i try to load this into an array , it does not return all the information. It will if a smaller amount of data is sought. For example if only 1 months month of data is requested. Is there a maximum data limit that can be parsed into an array with this method?
2. I'm not quite sure how to parse individual lines (records) to update a table in access. I have provided the code that I'm trying to use to accomplish this below. From code below am I doing this correctly?
3. For each record that is created in the database I would like to add a ticker string to the record for later querying. Can this be done and am I on the right track from the supplied code?
Any Help would be appreciated
Thanks
I'm trying to upload a csv file into an Array then add records to a table.
I have the following code which gets the information from a csv file which works fine.
Open filePath For Input As #1
Do While Not EOF(1)
Line Input #1, MyData
Problems:
1. When i try to load this into an array , it does not return all the information. It will if a smaller amount of data is sought. For example if only 1 months month of data is requested. Is there a maximum data limit that can be parsed into an array with this method?
2. I'm not quite sure how to parse individual lines (records) to update a table in access. I have provided the code that I'm trying to use to accomplish this below. From code below am I doing this correctly?
3. For each record that is created in the database I would like to add a ticker string to the record for later querying. Can this be done and am I on the right track from the supplied code?
Private Sub ImportData(filePath As String, ticker As String)
'On Error GoTo Errorhandler
Dim arrData() As String
Dim MyData As String
Dim i As Integer
Dim Db As DAO.Database
Dim rst As DAO.Recordset
Set Db = CurrentDb
Set rst = Db.OpenRecordset("Quotes1")
Open filePath For Input As #1
Do While Not EOF(1)
Line Input #1, MyData
arrData = Split(MyData, ",")
For i = 0 To UBound(arrData)
Debug.Print arrData(i)
' Add Data to Database Table.
With rst
.AddNew
!qTicker = ticker
!qDate = CDate(arrData(i))
!qOp = CDbl(arrData(i + 1))
!qHi = CDbl(arrData(i + 2))
!qLo = CDbl(arrData(i + 3))
!qCl = CDbl(arrData(i + 4))
!qVo = CDbl(arrData(i + 5))
.Update
End With
Next i
Loop
Close #1
rst.Close
Set rst = Nothing
Set Db = Nothing
'Getout:
'Exit Sub
'Errorhandler:
'MsgBox "Error #" & Err & ": " & Err.Description
'Resume Getout
End Sub
Any Help would be appreciated
Thanks