Question : i keep getting runtime error 9 subscript out of range

hi all, i keep getting runtime error 9 subscript out of range. i think it may be on the strSQL line at splitText3(1) which is part of an array..

any ideas would be greatly appreciated (as always)

thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Case "DIN"
            ' Add date in factory if DIN
            splitText1 = Split(txtLine, "=")
            splitText2 = Split(splitText1(1), "+")
            strChange2 = splitText2(0)
            output = output & "Depot Date " & " - " & Right(strChange2, 2) & "/" & Mid(strChange2, 3, 2) & "/" & Left(strChange2, 2) & vbCrLf
             If DCount("DepotDate", "OrderInfo", "DepotDate='" & strChange2 & "'") = 0 Then 'DCount determines DepotDate in the OrderInfo table is 0 (empty)
                strSQL = "INSERT INTO OrderInfo (DepotDate,OrderDate,OrderNo) VALUES ('" & strChange2 & "' & strChange1 '" & splitText3(1) & "')"
                DoCmd.RunSQL strSQL 'If it is empty run the SQL INSERT INTO statement
             End If

Answer : i keep getting runtime error 9 subscript out of range

OK. Try this:
1. Add redim splittext3(0) where it was.
2. Add Dim strChange3 As String at the top.
3. In Case ORD, add strChange3 = splitText3(1).
4. In Case DIN, replace splitText3(1) with strChange3 in the SQL string.
-Chuck
Random Solutions  
 
programming4us programming4us