G
Guest
Hi Everyone,
Access 2003, XP Pro
I use this function to assign a value to [linnum].
"Option Compare Database
Public Function AssignNumbersBudgetLines()
' Assign linnum to tblBudgetLines
Dim count, cycles, linecount As String
cycles = 0 'how many loops
count = 0 ' number of records
linecount = "01" ' increment for line items
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
strSql = "select tblBudgetLines.* from tblBudgetLines order by phsnum,Match"
Set rst = dbs.OpenRecordset(strSql)
Set rst = dbs.OpenRecordset("tblBudgetLines", dbOpenTable)
rst.MoveLast
rst.MoveFirst
count = rst.RecordCount
Do Until cycles = count
With rst
.Edit
![linnum] = linecount
.Update
rst.MoveNext
linecount = linecount + 1
cycles = cycles + 1
End With
Loop
rst.Close
End Function"
How can I modify this so that I restart numbering each time the function
encounters a new [phsnum]?
For Example:
phsnum Match linnum
01 1000 1
01 2000 2
01 3000 3
02 1000 1
02 1500 2
03 5000 1
TIA
Access 2003, XP Pro
I use this function to assign a value to [linnum].
"Option Compare Database
Public Function AssignNumbersBudgetLines()
' Assign linnum to tblBudgetLines
Dim count, cycles, linecount As String
cycles = 0 'how many loops
count = 0 ' number of records
linecount = "01" ' increment for line items
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
strSql = "select tblBudgetLines.* from tblBudgetLines order by phsnum,Match"
Set rst = dbs.OpenRecordset(strSql)
Set rst = dbs.OpenRecordset("tblBudgetLines", dbOpenTable)
rst.MoveLast
rst.MoveFirst
count = rst.RecordCount
Do Until cycles = count
With rst
.Edit
![linnum] = linecount
.Update
rst.MoveNext
linecount = linecount + 1
cycles = cycles + 1
End With
Loop
rst.Close
End Function"
How can I modify this so that I restart numbering each time the function
encounters a new [phsnum]?
For Example:
phsnum Match linnum
01 1000 1
01 2000 2
01 3000 3
02 1000 1
02 1500 2
03 5000 1
TIA