D
dp724 via AccessMonster.com
Hi folks,
I'm using the code module below to create a extra column which will number,
in serial order, the records produced by my query. The problem is that when
it creates the number list and the list reaches a record in the reference
field which is repeated, it repeats the number used when the record was
first encountered, like shown below. How can I edit the code or correct the
issue so that number continue in serial order '1 thru 6'.
ConstMon No.
Jan 1
Feb 2
Mar 3
Apr 4
Feb 2
Mar 3
Jan 1
Function Serialize(qryname As String, keyname As String, keyvalue) As Long
On Error GoTo Err_Serialize
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)
rs.FindFirst Application.BuildCriteria(keyname, rs.Fields(keyname).Type,
keyvalue)
Serialize = Nz(rs.AbsolutePosition, -1) + 1
Err_Serialize:
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
SQL:
SELECT QryDiscChart7.ConstMon, Serialize("QryDiscChart12","ConstMon",
[ConstMon]) AS Expr1
FROM QryDiscChart7;
Thanks in advance.
Dave
I'm using the code module below to create a extra column which will number,
in serial order, the records produced by my query. The problem is that when
it creates the number list and the list reaches a record in the reference
field which is repeated, it repeats the number used when the record was
first encountered, like shown below. How can I edit the code or correct the
issue so that number continue in serial order '1 thru 6'.
ConstMon No.
Jan 1
Feb 2
Mar 3
Apr 4
Feb 2
Mar 3
Jan 1
Function Serialize(qryname As String, keyname As String, keyvalue) As Long
On Error GoTo Err_Serialize
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)
rs.FindFirst Application.BuildCriteria(keyname, rs.Fields(keyname).Type,
keyvalue)
Serialize = Nz(rs.AbsolutePosition, -1) + 1
Err_Serialize:
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
SQL:
SELECT QryDiscChart7.ConstMon, Serialize("QryDiscChart12","ConstMon",
[ConstMon]) AS Expr1
FROM QryDiscChart7;
Thanks in advance.
Dave