D
DS
I have this loop statement that is almost working, the problem is that
instead of starting at the first record, making it the next highest
LineID available, then going to the next and makeing that the next
LineID +1 its just finding the highest Line ID at the end of the
recordset and making all the LineID's in every record that one.
I should have this//
1
2
3
4
5
6
but I'm getting this
6
6
6
6
6
6
Any Help Appreciated,
Thanks
DS
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM SplitHold WHERE
SplitHold.SalesID = " & Me.TxtLeftID & "", dbOpenDynaset)
With rst
Do Until .EOF
Me.TxtNextLine = DMax("LineID", "SplitHold", "SalesID =
Forms!MoveItem!TxtLeftID")
Me.TxtNextLine = Me.TxtNextLine + 1
Dim NewSQL As String
DoCmd.SetWarnings False
NewSQL = "UPDATE SplitHold SET
SplitHold.LineID=Forms!MoveItem!TxtNextLine " & _
"WHERE SplitHold.SalesID = Forms!MoveItem!TxtLeftID;"
DoCmd.RunSQL (NewSQL)
DoCmd.SetWarnings True
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
instead of starting at the first record, making it the next highest
LineID available, then going to the next and makeing that the next
LineID +1 its just finding the highest Line ID at the end of the
recordset and making all the LineID's in every record that one.
I should have this//
1
2
3
4
5
6
but I'm getting this
6
6
6
6
6
6
Any Help Appreciated,
Thanks
DS
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM SplitHold WHERE
SplitHold.SalesID = " & Me.TxtLeftID & "", dbOpenDynaset)
With rst
Do Until .EOF
Me.TxtNextLine = DMax("LineID", "SplitHold", "SalesID =
Forms!MoveItem!TxtLeftID")
Me.TxtNextLine = Me.TxtNextLine + 1
Dim NewSQL As String
DoCmd.SetWarnings False
NewSQL = "UPDATE SplitHold SET
SplitHold.LineID=Forms!MoveItem!TxtNextLine " & _
"WHERE SplitHold.SalesID = Forms!MoveItem!TxtLeftID;"
DoCmd.RunSQL (NewSQL)
DoCmd.SetWarnings True
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing