Program was working, now not working runtime erros

rcorrea
01-08-2004, 08:14 PM
I have a program that searches through a recordset for indexes to lines in an order.

The program worked fine until the owner re-indexed or rebuilt all the indexes. Basically all the pointers changed for these lines, and now my program is freakin out and saying it cant find data.

Heres the code that previously worked, and STILL works on some orders.
vb
Private Sub Command1_Click()

Set rstMyrecset = Nothing
Set Mas90 = Nothing

Do Until strNextline = 0

If Ordernumber <> strSalesorder Then
MsgBox Err.Source & "The order number has changed." & _
"This order is crosslinked." & Err.Description, , "Error"
GoTo error:
End If

cmdMyrecset.CommandText = "SELECT LineIndex, LinkToNextLine," & _
" SalesOrderNumber, LinkToPrevLine FROM SO2_SOEntryDetailLine WHERE" & _
"(LineIndex LIKE '%" & strNextline & "')"
Set rstMyrecset = cmdMyrecset.Execute

strLineindex = rstMyrecset.Fields.Item("LineIndex").Value
strPrevline = rstMyrecset.Fields.Item("LinkToPrevLine").Value
strNextline = rstMyrecset.Fields.Item("LinkToNextLine").Value
strSalesorder = rstMyrecset.Fields.Item("SalesOrderNumber").Value

txtLineindex.Text = strLineindex
txtPrevline.Text = strPrevline
txtNextline.Text = strNextline
txtOrdernumber.Text = strSalesorder

txtLineindex.Refresh
txtPrevline.Refresh
txtNextline.Refresh
txtOrdernumber.Refresh

'Sleep 1000
'DoEvents

'Open "c:\windows\desktop\mylog.txt" For Append As #1
'Print #1, "Previous Line "; strPrevline, "Next Line "; strNextline, "Line Index "; strLineindex
'Close #1


Loop
MsgBox "The order started at 00 and ended in 00, and the order number did " & _
"not change. Pre-checking can be notified this order is OK."


error:
txtLineindex.Text = 0
txtPrevline.Text = 0
txtNextline.Text = 0
txtOrdernumber.Text = ""
txt02pointer.Text = 0


quit:
End Sub
/vb

I believe the offending code is the SELECT statement. The select statement gets the lines, and checks the order, to make sure no lines are crosslinked into another order. On some orders, it works fine, but others, where the lines are low numbers such as 1, 2, or 3, the program bombs, with a FILE i/o error: data not found.

Shurik12
01-09-2004, 02:17 AM
Hi,

Hmmm indeed quite strange, if it's only about reindexing or rebuilding the indexes (and not changing fields' datatype or so)

What do you mean by "...the lines are low numbers such as 1, 2, or 3" ?

Regards,
Shurik.

rcorrea
01-09-2004, 10:44 AM
The indexes are pointers to lines in an order. So "nextline" could be 3375, and the previous line could be 3345. The numbers are just pointers in the database. The program checks those pointers against the order number. If one of the pointers suddenly shifts and points to another order number then that line is crosslinked.

The program worked fine until these pointers suddenly are real low, such as 1, 2, or 3. This is a toughie, because its hard to explain :)


Hi,

Hmmm indeed quite strange, if it's only about reindexing or rebuilding the indexes (and not changing fields' datatype or so)

What do you mean by "...the lines are low numbers such as 1, 2, or 3" ?

Regards,
Shurik.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum