Hi,
I don't seem to be able to create a simple string array, I must be doing something really stupid, so all help is appreciated.
If i breakpoint the code and hover over 'vVal(iCnt)' i get a 'subscript out of range' error, yet iCnt = 1 ?
So I'm assuming although
vVal = Array(sVal)
didn't error , it can't have created an array of strings?
What am I doing wrong?
Thanks, 1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
I don't seem to be able to create a simple string array, I must be doing something really stupid, so all help is appreciated.
Code:
Dim rs As DAO.Recordset
Dim sCols As String
Dim sData As String
Dim iCnt As Integer
Dim vFld As Variant
Dim vVal As Variant
Dim sFld As String
Dim sVal As String
Dim sProv As String
Dim sProv_Type As String
Set rs = CurrentDb.OpenRecordset("SELECT * FROM [Provider_Import_Map] WHERE 1=1", dbOpenSnapshot, dbSeeChanges)
sFld = ""
sVal = ""
For iCnt = 0 To (rs.Fields.Count - 1)
sFld = sFld & "," & rs.Fields.Item(iCnt).Name
sVal = sVal & "," & rs.Fields.Item(iCnt).Value
Next iCnt
vFld = Array(sFld)
vVal = Array(sVal)
Set rs = Nothing
Set rs = CurrentDb.OpenRecordset("SELECT * FROM [Provider_Import] WHERE 1=1", dbOpenSnapshot, dbSeeChanges)
sCols = ""
sData = ""
Do While Not rs.EOF
For iCnt = 1 To UBound(vFld)
If sCols <> "" Then
sCols = sCols & ","
End If
sCols = sCols & vVal(iCnt)
MsgBox rs.Fields.Item(iCnt).Type
Next iCnt
rs.MoveNext
Loop
If i breakpoint the code and hover over 'vVal(iCnt)' i get a 'subscript out of range' error, yet iCnt = 1 ?
So I'm assuming although
vVal = Array(sVal)
didn't error , it can't have created an array of strings?
What am I doing wrong?
Thanks, 1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!