Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / December 2005

Tip: Looking for answers? Try searching our database.

record number

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jon Rowlan - 01 Dec 2005 22:35 GMT
I wish to number records, in natural order from 1 to n

There is no numerical or date comparison or sort that will allow be to rank
using the techniques listed (that rely on there being count() records in my
query that are logically lower than the current record.

Is there any way to apply a simple record number (like the old
clipper/dbase/foxpro recno()) without relying on a comparison.

jON
Tom Ellison - 01 Dec 2005 22:53 GMT
Dear Jon:

If is is the case that there is no row, or combination of rows, that
uniquely identify the rows in a table, then the only way would be to use a
random number to give them values and sort by that.  Even then, there is no
guarantee of uniqueness.

If the rows in your table do not have a unique order then a query won't
help.

You could open the table using VBA as a recordset and assign sequential
numbers to them.

You could add an autonumber column.

Just for the purpose of theoretical research, what would be accomplished for
you by assigning numbers to them?  What would this allow you to do which you
cannot do without numbering?

Tom Ellison

>I wish to number records, in natural order from 1 to n
>
[quoted text clipped - 6 lines]
>
> jON
John Vinson - 02 Dec 2005 00:13 GMT
>I wish to number records, in natural order from 1 to n

A table HAS NO ORDER. That's like asking to number the potatoes in a
wheelbarrow in "natural order". Access will store new records in a
table in whatever order is convenient; sure, they'll usually be
sequential, but you CANNOT count on it.

If need be you can add a Long Integer field and open a Recordset:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim iRec As Long
Set db = CurrentDb
Set rs = db.OpenRecordset("yourtable", dbOpenDynaset)
iRec = 1
Do Until rs.EOF
    rs!RecNo = iRec
    iRec = iRec+1
    rs.MoveNext
Loop

                 John W. Vinson[MVP]    
SteveS - 02 Dec 2005 14:45 GMT
I'm working nights, so maybe I'm not too alert. But don't you need

rs.Edit and rs.Update in the loop???

Do Until rs.EOF
               rs.Edit       '<<<
    rs!RecNo = iRec
    rs.Update  '<<<
               iRec = iRec+1
    rs.MoveNext
Loop

(Trying to stay awake by reading the NG.......)
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

John Vinson - 02 Dec 2005 17:48 GMT
>I'm working nights, so maybe I'm not too alert. But don't you need
>
>rs.Edit and rs.Update in the loop???

Absolutely. You're wide awake and alert it seems, it's me who wasn't!

                 John W. Vinson[MVP]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.