Sequential Number in Query (2 Viewers)

JAQ

New member
Local time
Today, 15:25
Joined
Dec 15, 2021
Messages
9
Hi

I am looking for a solution as i haven't any ID field in my query what i need is a sequential number from 1 to so on which shall count rows only in query
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:25
Joined
Oct 29, 2018
Messages
21,467
No ID, but do you have another unique column available? If not, you will need a custom counter function.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:25
Joined
Feb 28, 2001
Messages
27,172
There is a conceptual problem here. If you have no ID (or any other type of field) that you can use to provide order to your query, you can number the rows but those numbers will mean nothing. If you update any field in any record in that table, the numbers will be different the next time you open that query.

This happens because your underlying table has no inherent order - particularly since you denied having a usable ID field. Therefore, unless you can provide at least some semblance of a field to support a sort order, your query-based number will be useful only for picking random lottery numbers. Look through the articles linked below in the "Similar Threads" section to see if you get any ideas.

Try this Google search: "Can I add an autonumber field to an access table?"
 

JAQ

New member
Local time
Today, 15:25
Joined
Dec 15, 2021
Messages
9
There is a conceptual problem here. If you have no ID (or any other type of field) that you can use to provide order to your query, you can number the rows but those numbers will mean nothing. If you update any field in any record in that table, the numbers will be different the next time you open that query.

This happens because your underlying table has no inherent order - particularly since you denied having a usable ID field. Therefore, unless you can provide at least some semblance of a field to support a sort order, your query-based number will be useful only for picking random lottery numbers. Look through the articles linked below in the "Similar Threads" section to see if you get any ideas.

Try this Google search: "Can I add an autonumber field to an access table?"
Dear thanks, I just need a column in query which shows row numbers for that particular records in query
 

oleronesoftwares

Passionate Learner
Local time
Today, 03:25
Joined
Sep 22, 2014
Messages
1,159
Dear thanks, I just need a column in query which shows row numbers for that particular records in query
You haven't answered the questions raised by @theDBguy and @The_Doc_Man with regards to whether a unique field exists, without understanding how records in the table are organised, it might be difficult to advise well.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:25
Joined
Feb 19, 2002
Messages
43,263
Regarding Uncle's suggestion ----
Both of these methods require a unique column in the table to create the sequence on.

Maj's suggestion ALSO requires something on which to order the set of records.

That brings us back to the initial questions On what do you propose to sequence the rows?

!. Having no uniqueID for a table is simply poor practice. If you don't have a unique candidate key, use an autonumber.
2. Without a "seed", you need a sequential process to come up with a sequence. This is trivial in a report because reports are produced sequentially. If the number is to be used in a report, this is the best solution. Use the Over All or Over group property to "count" the rows to print.

Relational tables are unordered sets. They do NOT have the concept of a record number. Neither does a query.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:25
Joined
May 21, 2018
Messages
8,527
If you don't have a unique candidate key, use an autonumber.
The mileage is both unique and ordered and makes a good natural PK. It is always increasing. AFAIK you cannot drive a car and then fill up without the mileage increasing and being unique. I guess you can worry about the case where the odometer fails and you reset it or get a new odometer. At that point it is probably a new query.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:25
Joined
Feb 19, 2002
Messages
43,263
The mileage is both unique and ordered and makes a good natural PK.
Do you know something we don't know about the OP's database:)
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:25
Joined
Feb 28, 2001
Messages
27,172
@MajP - are you perhaps confusing this person with someone else? I just looked at all four of JAQ's posts and NONE of them mention mileage. Can you point to the post with the word mileage? Because your point is well taken, but either you have a PM from this person or your crystal ball is working and mine is on the fritz.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:25
Joined
May 21, 2018
Messages
8,527
@MajP - are you perhaps confusing this person with someone else? I just looked at all four of JAQ's posts and NONE of them mention mileage. Can you point to the post with the word mileage? Because your point is well taken, but either you have a PM from this person or your crystal ball is working and mine is on the fritz.
Thanks. Definitely the wrong post.
 

Users who are viewing this thread

Top Bottom