sparlaman1
Registered User.
- Local time
- Yesterday, 16:00
- Joined
- Apr 1, 2014
- Messages
- 13
I am trying to assign line numbers to records in my query. I have found the http://www.lebans.com/rownumber.htm Serialize Function as follows:
Function Serialize(qryname As String, keyname As String, keyvalue) As Long
Dim rs As Recordset
On Error GoTo Err_Serialize
Set rs = CurrentDb.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
End Function
but I don't know how to implement this. I'm sure I need to change some of the code to match tables/fields in my database but what part of the code do I change. And where/how do I reference this in my query to give me the line numbers I'm looking for?
Most of the time I can figure this out but this is eluding me. Any help is greatly appreciated!
Function Serialize(qryname As String, keyname As String, keyvalue) As Long
Dim rs As Recordset
On Error GoTo Err_Serialize
Set rs = CurrentDb.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
End Function
but I don't know how to implement this. I'm sure I need to change some of the code to match tables/fields in my database but what part of the code do I change. And where/how do I reference this in my query to give me the line numbers I'm looking for?
Most of the time I can figure this out but this is eluding me. Any help is greatly appreciated!