P
PatK
Hi! I am making my first foray into arrays and am running into a problem.
WHen I run this code, I am getting an error: Runtime Error 9, subscript out
of range (I have noted the point where DEBUG is pointing to the error. Is
the problem my user defined datatype? Do I have to "ReDim" the array
somehow, inside the subroutine?
ARGGGG...! Help
Thanks! PatK
Option Compare Database
Type dtype
strNameIn() As String
IntInputOrder() As Integer
strDataType() As String
strNameOut() As String
IntMaxLen() As Integer
intOutputOrder() As Integer
strDataSrcTbl() As String
strDataSrcFld() As String
End Type
------------------------------------------------------------------------
Sub xformData()
Dim xArray As dtype
Dim rs As ADODB.Recordset
Dim strSelect As String
Dim strDTypein As String
Dim strOutTbl As String
Dim strYourDB As String
Dim i As Integer
strDTypein = "EVOpen"
strOutTbl = "Tbl-Tickets"
strSelect = "DataType='" & strDTypein & "'"
Set rs = New ADODB.Recordset
With rs
.Open "TblStructure", CurrentProject.Connection, adOpenStatic, _
adLockPessimistic
.MoveFirst
.Find strSelect
i = 0
Debug.Print strSelect;
Do Until .EOF
Debug.Print i; <- this is equal to zero on first/failing loop
xArray.strNameIn(i) = rs.Fields("FieldName-Input") <- Getting error
here
xArray.strDataType(i) = rs.Fields("FieldType")
MsgBox "Fieldname: " & xArray.strNameIn(i) & " DataType: " & _
xArray.strDataType(i)
i = i + 1
.Find strSelect, 1
Loop
End With
rs.Close
Set rs = Nothing
End Sub
WHen I run this code, I am getting an error: Runtime Error 9, subscript out
of range (I have noted the point where DEBUG is pointing to the error. Is
the problem my user defined datatype? Do I have to "ReDim" the array
somehow, inside the subroutine?
ARGGGG...! Help
Thanks! PatK
Option Compare Database
Type dtype
strNameIn() As String
IntInputOrder() As Integer
strDataType() As String
strNameOut() As String
IntMaxLen() As Integer
intOutputOrder() As Integer
strDataSrcTbl() As String
strDataSrcFld() As String
End Type
------------------------------------------------------------------------
Sub xformData()
Dim xArray As dtype
Dim rs As ADODB.Recordset
Dim strSelect As String
Dim strDTypein As String
Dim strOutTbl As String
Dim strYourDB As String
Dim i As Integer
strDTypein = "EVOpen"
strOutTbl = "Tbl-Tickets"
strSelect = "DataType='" & strDTypein & "'"
Set rs = New ADODB.Recordset
With rs
.Open "TblStructure", CurrentProject.Connection, adOpenStatic, _
adLockPessimistic
.MoveFirst
.Find strSelect
i = 0
Debug.Print strSelect;
Do Until .EOF
Debug.Print i; <- this is equal to zero on first/failing loop
xArray.strNameIn(i) = rs.Fields("FieldName-Input") <- Getting error
here
xArray.strDataType(i) = rs.Fields("FieldType")
MsgBox "Fieldname: " & xArray.strNameIn(i) & " DataType: " & _
xArray.strDataType(i)
i = i + 1
.Find strSelect, 1
Loop
End With
rs.Close
Set rs = Nothing
End Sub