Connecting Tech Pros Worldwide Help | Site Map

get the record number from the access db

Newbie
 
Join Date: Nov 2006
Posts: 15
#1: Dec 9 '06
hai,
I want to get the record number in access using select statement. please help. Thanks in advance.
indra.G
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,865
#2: Dec 9 '06

re: get the record number from the access db


Quote:

Originally Posted by indrag91

hai,
I want to get the record number in access using select statement. please help. Thanks in advance.
indra.G

indra

You cannot get a record number in access. You can only identify it by it's primary key or other unique value.

Mary
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,214
#3: Dec 10 '06

re: get the record number from the access db


Quote:

Originally Posted by indrag91

hai,
I want to get the record number in access using select statement. please help. Thanks in advance.
indra.G

'As far as I know, you cannot retrieve it via a SELECT Statement but this is
'how I retrieve it via VBA coding:

Expand|Select|Wrap|Line Numbers
  1. Dim recClone As DAO.Recordset
  2.  
  3. Set recClone = Me.RecordsetClone()             'Copy of the Form's underlying Recordset
  4. recClone.Bookmark = Me.Bookmark             'Resync Bookmarks
  5. Debug.Print recClone.AbsolutePosition + 1    'Returns the Record Number
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,865
#4: Dec 10 '06

re: get the record number from the access db


Nice piece of code ADezii.

I assume it only works if the form is based on the table with no criteria or sort order.

Mary

Quote:

Originally Posted by ADezii

'As far as I know, you cannot retrieve it via a SELECT Statement but this is
'how I retrieve it via VBA coding:

Expand|Select|Wrap|Line Numbers
  1. Dim recClone As DAO.Recordset
  2.  
  3. Set recClone = Me.RecordsetClone()             'Copy of the Form's underlying Recordset
  4. recClone.Bookmark = Me.Bookmark             'Resync Bookmarks
  5. Debug.Print recClone.AbsolutePosition + 1    'Returns the Record Number

Newbie
 
Join Date: Nov 2006
Posts: 15
#5: Dec 11 '06

re: get the record number from the access db


Quote:

Originally Posted by mmccarthy

Nice piece of code ADezii.

I assume it only works if the form is based on the table with no criteria or sort order.

Mary

Sir,
I have created a database in access and iam using vb as front end. For the data report the data source is dataenvironment.For e.g I have nearly 100 records and i am selecting few records based on a condition in the dataenvironment sql command(select * from contract where vtcno>?) and placing the dataenvironment as the data source to the data reort. The selected records should be numbered(1,2,3...) in the data report by adding an additional field in the data report.
thnaks
indra
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,865
#6: Dec 11 '06

re: get the record number from the access db


If you are creating your frontend in VB you might want to post this in the Visual Basic forum as well. Some of their experts do hang out here but you are more likely to get an answer to your question over there.

Mary
Reply