T
Tom
I am receiving the error messgae "Subscript out of
range". I know why I'm recieving it, but can't figure out
how to fix it. Here is my code:
' To read the Array ...
Dim i As Integer, a$
Dim strSQL As String
Dim strInjuryType1 As String
Dim strInjuryType2 As String
Dim strInjuryType3 As String
Dim strInjuryType4 As String
Dim strInjuryType5 As String
Dim strInjuryType6 As String
Dim strInjuryType7 As String
Dim strInjuryType8 As String
Dim strInjuryType9 As String
Dim strInjuryType10 As String
Dim strInjuryType11 As String
For i = 0 To UBound(ParseString)
a$ = a$ & ParseString(i) & vbNewLine
Next i
MsgBox "Your Array Contains:" & vbNewLine & vbNewLine
& a$
strInjuryType1 = ParseString(0)
strInjuryType2 = ParseString(1)
strInjuryType3 = ParseString(2)
strInjuryType4 = ParseString(3)
strInjuryType5 = ParseString(4)
strInjuryType6 = ParseString(5)
strInjuryType7 = ParseString(6)
strInjuryType8 = ParseString(7)
strInjuryType9 = ParseString(8)
strInjuryType10 = ParseString(9)
strInjuryType11 = ParseString(10)
strSQL = "INSERT INTO tblInjuriesperClaimECA
([ClaimNumber],[InjuryType1],[InjuryType2],[InjuryType3],
[InjuryTyp4],[InjuryType5],[InjuryType6],[InjuryType7],
[InjuryType8],[InjuryType9],[InjuryType10])VALUES ('" &
strClaimNumber & "','" & strInjuryType1 & "','" &
strInjuryType2 & "','" & strInjuryType2 & "','" &
strInjuryType2 & "','" & strInjuryType2 & "','" &
strInjuryType2 & "','" & strInjuryType2 & "','" &
strInjuryType3 & "','" & strInjuryType4 & "','" &
strInjuryType5 & "','" & strInjuryType6 & "','" &
strInjuryType7 & "','" & strInjuryType8 & "','" &
strInjuryType9 & "','" & strInjuryType10 & "','" &
strInjuryType11 & "');"
CurrentDb.Execute strSQL
As it reads the array, if there is no value, it doesn't
know what to do. I need to add a loop so that if it sees
a null value, it repeats the code again. In the above
example, it reads the array and since the array only has
three values, it gives me the error when it tries to
declare the fourth value. There can be up to 10 values in
the array.
Thank you so much for your help.
range". I know why I'm recieving it, but can't figure out
how to fix it. Here is my code:
' To read the Array ...
Dim i As Integer, a$
Dim strSQL As String
Dim strInjuryType1 As String
Dim strInjuryType2 As String
Dim strInjuryType3 As String
Dim strInjuryType4 As String
Dim strInjuryType5 As String
Dim strInjuryType6 As String
Dim strInjuryType7 As String
Dim strInjuryType8 As String
Dim strInjuryType9 As String
Dim strInjuryType10 As String
Dim strInjuryType11 As String
For i = 0 To UBound(ParseString)
a$ = a$ & ParseString(i) & vbNewLine
Next i
MsgBox "Your Array Contains:" & vbNewLine & vbNewLine
& a$
strInjuryType1 = ParseString(0)
strInjuryType2 = ParseString(1)
strInjuryType3 = ParseString(2)
strInjuryType4 = ParseString(3)
strInjuryType5 = ParseString(4)
strInjuryType6 = ParseString(5)
strInjuryType7 = ParseString(6)
strInjuryType8 = ParseString(7)
strInjuryType9 = ParseString(8)
strInjuryType10 = ParseString(9)
strInjuryType11 = ParseString(10)
strSQL = "INSERT INTO tblInjuriesperClaimECA
([ClaimNumber],[InjuryType1],[InjuryType2],[InjuryType3],
[InjuryTyp4],[InjuryType5],[InjuryType6],[InjuryType7],
[InjuryType8],[InjuryType9],[InjuryType10])VALUES ('" &
strClaimNumber & "','" & strInjuryType1 & "','" &
strInjuryType2 & "','" & strInjuryType2 & "','" &
strInjuryType2 & "','" & strInjuryType2 & "','" &
strInjuryType2 & "','" & strInjuryType2 & "','" &
strInjuryType3 & "','" & strInjuryType4 & "','" &
strInjuryType5 & "','" & strInjuryType6 & "','" &
strInjuryType7 & "','" & strInjuryType8 & "','" &
strInjuryType9 & "','" & strInjuryType10 & "','" &
strInjuryType11 & "');"
CurrentDb.Execute strSQL
As it reads the array, if there is no value, it doesn't
know what to do. I need to add a loop so that if it sees
a null value, it repeats the code again. In the above
example, it reads the array and since the array only has
three values, it gives me the error when it tries to
declare the fourth value. There can be up to 10 values in
the array.
Thank you so much for your help.