I
InAFix
Hi -
I hope I can explain this throughly enough:
I have a table, imported, that needs to have line numbers assigend
that will correspond to the line numbers displayed on the screen of
the source program. The table is imported via an ODBC link. The line
numbers assigned will be used in an Access report.
When the rows/records of the table are added (in the source program),
they are assigned a unique value called LineIndex, a link to the
previous line called PrevIndex and a link to the following line called
NextIndex. The lines collectively make up the details of an order.
So the first line of the order may have a LineIndex of 10, a PrevIndex
of zero (the first line has no previous line), a NextIndex of 21.
(Lines are added to the end of the source file, so they aren't
consecutive) It is easy enough to know that if the PrevIndex is zero,
then the LineNumber should be 1.
Here is a sample of what I've come up with so far, but I'm having many
troubles "walking" through the set of records. I think I'm missing
some way of determining the total number lines per order, so that the
loop knows when I've reached the end for that order, and then I'm
obviously missing some way of moving to the next order (I'm no expert
- but I think that's what I'm missing!)
I need to be able to:
Find the first line (with order number, PrevIndex = zero) and assign
it line number 1. Then using that line's NextIndex, find the line
where the LineIndex equals the NextIndex and assign it number two, and
so on, until I've numbered all the lines related to that order, then
move onto the next order and repeat the process, eventually coming to
the end when all the order's lines have a line number.
I'd be ever so greatful for any input/ideas.
tia
'-----------------------
Function LineNumber(Order, LineIndex, NextIndex, PrevIndex) As Long
Dim i As Integer
Dim NextLine As Integer
NextLine = (LineIndex = NextIndex)
Dim Rs as Recordset
i = 1
If Not IsNull(Order) Then
If Not IsNull(LineNumber) Then
If PrevIndex = 0 Then
LineNumber = 1
ElseIf PrevIndex <> 0 Then
rs.MoveFirst
With Order
Do Until NextIndex = 0
With LineIndex
If LineIndex = NextIndex Then
LineNumber = i + 1
End If
End With
rs.MoveNext
'move next
'start at top
Loop
End With
End If
End If
End If
End Function
'---------------------------
I hope I can explain this throughly enough:
I have a table, imported, that needs to have line numbers assigend
that will correspond to the line numbers displayed on the screen of
the source program. The table is imported via an ODBC link. The line
numbers assigned will be used in an Access report.
When the rows/records of the table are added (in the source program),
they are assigned a unique value called LineIndex, a link to the
previous line called PrevIndex and a link to the following line called
NextIndex. The lines collectively make up the details of an order.
So the first line of the order may have a LineIndex of 10, a PrevIndex
of zero (the first line has no previous line), a NextIndex of 21.
(Lines are added to the end of the source file, so they aren't
consecutive) It is easy enough to know that if the PrevIndex is zero,
then the LineNumber should be 1.
Here is a sample of what I've come up with so far, but I'm having many
troubles "walking" through the set of records. I think I'm missing
some way of determining the total number lines per order, so that the
loop knows when I've reached the end for that order, and then I'm
obviously missing some way of moving to the next order (I'm no expert
- but I think that's what I'm missing!)
I need to be able to:
Find the first line (with order number, PrevIndex = zero) and assign
it line number 1. Then using that line's NextIndex, find the line
where the LineIndex equals the NextIndex and assign it number two, and
so on, until I've numbered all the lines related to that order, then
move onto the next order and repeat the process, eventually coming to
the end when all the order's lines have a line number.
I'd be ever so greatful for any input/ideas.
tia
'-----------------------
Function LineNumber(Order, LineIndex, NextIndex, PrevIndex) As Long
Dim i As Integer
Dim NextLine As Integer
NextLine = (LineIndex = NextIndex)
Dim Rs as Recordset
i = 1
If Not IsNull(Order) Then
If Not IsNull(LineNumber) Then
If PrevIndex = 0 Then
LineNumber = 1
ElseIf PrevIndex <> 0 Then
rs.MoveFirst
With Order
Do Until NextIndex = 0
With LineIndex
If LineIndex = NextIndex Then
LineNumber = i + 1
End If
End With
rs.MoveNext
'move next
'start at top
Loop
End With
End If
End If
End If
End Function
'---------------------------