HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

how to add row numbers (record counting) to access query field

29,435 views November 15, 2017 3:38

Watch on YouTube
ChannelThe-Good-Fox

Description from the creator

how to add row numbers field in access database query
the code :

'copy this code as it is
'#################################
Private lngRowNumber As Long
Private colPrimaryKeys As VBA.Collection

Public Function ResetRowNumber() As Boolean
Set colPrimaryKeys = New VBA.Collection
lngRowNumber = 0
ResetRowNumber = True
End Function

Public Function RowNumber(UniqueKeyVariant As Variant) As Long
Dim lngTemp As Long

On Error Resume Next
lngTemp = colPrimaryKeys(CStr(UniqueKeyVariant))
If Err.Number Then
lngRowNumber = lngRowNumber + 1
colPrimaryKeys.Add lngRowNumber, CStr(UniqueKeyVariant)
lngTemp = lngRowNumber
End If

RowNumber = lngTemp
End Function
'################################
'ps: this code is not mine but after a lot research this worked
'so thanks for the original owner of the code

Edit 09-Oct-2017:
it is essential to add ORDER BY SomeColumn; to the SQL statement so that the rows are in order correctly

About this tutorial

The-Good-Fox published this 3:38 video tutorial on November 15, 2017. It has been watched 29,435 times on YouTube.

Category
Education
Duration
3:38
Published
November 15, 2017
Views
29,435
Likes
162

Tags

Share

This tutorial in other languages