TuurCarlsen
New member
- Local time
- Today, 02:36
- Joined
- Feb 3, 2026
- Messages
- 2
4 steps:
1/ declare a global
Global glolngIncrementSequence As Long
2/ create a function
Public Function fncIncrementSequence(ByVal varDummy As Variant) As Long
' Very important: varDummy must be any non empty text value
glolngIncrementSequence = glolngIncrementSequence + 1
fncIncrementSequence = glolngIncrementSequence
End Function
3/ initiate the global
glolngIncrementSequence = 0
4/ run this query just using CategoryName as the Dummy (adding "x" is to avoid an empty value)
SELECT CategoryName, fncIncrementSequence(CategoryName & "x") AS Seq
FROM Categories
ORDER BY CategoryName
Guess how long it will take to create a table with 100.000 sequenced records ?
SELECT TOP 100000 fncIncrementSequence(a.ID & a.ID * Rnd) AS Seq
INTO tblTEST
FROM MSysObjects AS a, MSysObjects AS b, MSysObjects AS c, MSysObjects AS d, MSysObjects AS e
1/ declare a global
Global glolngIncrementSequence As Long
2/ create a function
Public Function fncIncrementSequence(ByVal varDummy As Variant) As Long
' Very important: varDummy must be any non empty text value
glolngIncrementSequence = glolngIncrementSequence + 1
fncIncrementSequence = glolngIncrementSequence
End Function
3/ initiate the global
glolngIncrementSequence = 0
4/ run this query just using CategoryName as the Dummy (adding "x" is to avoid an empty value)
SELECT CategoryName, fncIncrementSequence(CategoryName & "x") AS Seq
FROM Categories
ORDER BY CategoryName
Guess how long it will take to create a table with 100.000 sequenced records ?
SELECT TOP 100000 fncIncrementSequence(a.ID & a.ID * Rnd) AS Seq
INTO tblTEST
FROM MSysObjects AS a, MSysObjects AS b, MSysObjects AS c, MSysObjects AS d, MSysObjects AS e