Hello, and as a non-programmer I struggle much with 2D arrays. I waive the proverbial white flag of surrender, and any help would be most merciful.
I have a text download, which I have converted to a one dimensional array. But I would like to convert it to a two-dimensional array, which would have 3 columns. Finally, if possible, I would like to use the contents of the 2D array to populate an Access table.
So my initial dataset that Access imports from the clipboard looks like this, with pipes "|" separating values:
12345678 | 3346555 | 345.24 |
33448999 | 5566899 | 683.56 |
66655442 | 7774485 | 557.85 |
etc.
I have been able to create a 1D array, and then update a table with array contents with this code:
(only showing bottom half of the sub for simplicity sake, with variables properly dimensioned)
Code so far, and I suspect I would need to ReDim due to a varying number of rows:
Set rsINPUT1 = CurrentDb.OpenRecordset("INPUT1")
' Retrieve clipboard contents into data object, which has the separating pipes:
dataobj.GetFromClipboard
' Clipboard to string variable
strString = dataobj.GetText
' Convert string variable to array
arrayString = Split(strString, "|")
' Post Array to Table using DAO recordset
For i = 0 To UBound(arrayString) - 1
'Update Table with data from clipboard (realizing I am only showing 1 of 3 fields in the table)
rsINPUT1.AddNew
rsINPUT1!Field1 = arrayString(i)
rsINPUT1.Update
Next I
So my problems are 2-fold:
1) How do I first convert the imported text into a 2D array, and then
2) How do I populate the resulting 3 columns of data into records in the Access table, INPUT1?
Any help would be most appreciated, thanks in advance, PW.
I have a text download, which I have converted to a one dimensional array. But I would like to convert it to a two-dimensional array, which would have 3 columns. Finally, if possible, I would like to use the contents of the 2D array to populate an Access table.
So my initial dataset that Access imports from the clipboard looks like this, with pipes "|" separating values:
12345678 | 3346555 | 345.24 |
33448999 | 5566899 | 683.56 |
66655442 | 7774485 | 557.85 |
etc.
I have been able to create a 1D array, and then update a table with array contents with this code:
(only showing bottom half of the sub for simplicity sake, with variables properly dimensioned)
Code so far, and I suspect I would need to ReDim due to a varying number of rows:
Set rsINPUT1 = CurrentDb.OpenRecordset("INPUT1")
' Retrieve clipboard contents into data object, which has the separating pipes:
dataobj.GetFromClipboard
' Clipboard to string variable
strString = dataobj.GetText
' Convert string variable to array
arrayString = Split(strString, "|")
' Post Array to Table using DAO recordset
For i = 0 To UBound(arrayString) - 1
'Update Table with data from clipboard (realizing I am only showing 1 of 3 fields in the table)
rsINPUT1.AddNew
rsINPUT1!Field1 = arrayString(i)
rsINPUT1.Update
Next I
So my problems are 2-fold:
1) How do I first convert the imported text into a 2D array, and then
2) How do I populate the resulting 3 columns of data into records in the Access table, INPUT1?
Any help would be most appreciated, thanks in advance, PW.