Access access vba multiline textbox

Joined
Feb 26, 2013
Messages
12
Reaction score
0
Hi all before I explain my problem here is the vba code;

Private Sub Command69_Click()

Dim lines() As String

Dim OVENID, BUILDID, LOTNUMBER As String
Dim text As String

Dim i As Integer
i = 0

txtScans.SetFocus
txtScans.Value = UCase(txtScans.Value)
lines = Split(txtScans.text, vbCrLf)

Do While lines(i) > ""

If lines(i) Like "OVEN*" Then
'MsgBox ("HI")
OVENID = Right(lines(i), Len(lines(i)) - 4)
i = i + 1
Else

If OVENID > 0 Then
Else
OVENID = "0"
End If
End If

If lines(i) Like "BUIL*" Then
BUILDID = Right(lines(i), Len(lines(i)) - 4)
i = i + 1
Else

If BUILDID > 0 Then
Else
BUILDID = "777"
End If
End If

If lines(i) Like "L*" Then
LOTNUMBER = Right(lines(i), Len(lines(i)) - 1)
i = i + 1

ElseIf lines(i) Like "R*" Then
LOTNUMBER = lines(i)
i = i + 1
Else
End If

CurrentDb.Execute "INSERT INTO OVEN_BARCODE_SCANS(LotNumber, InspectionReceived, Builder) Values ('" & LOTNUMBER & "', '" & OVENID & "', '" & BUILDID & "')"
Loop

End Sub

The aim of this is to extract data from a multi line textbox and insert it into a table.... The problem I am getting is that I get runtime error 9: subscript out of range when there is no data on the next line of the multiline textbox. I need to exit the code when it reaches the end of the text of the multiline text box but on error goto commands dont work.. Any suggestions....

Thanks for taking the time to read this...

Billy
 
Never mind this has been sorted, I used On Error Resume Next and some other code to exit the sub under certain conditions.
 
Back
Top