Solved

Access 2000 - Autonumber in a Query

Posted on 2011-09-26
6
495 Views
Last Modified: 2012-05-12
Dear Experts,

Could you please advise is there way in Access 2000 to add an autonumber to a Query?

My problem is that the query has a certain ordering (in four fields like ascending, descending, descending, descending), and I would like to keep this order.

Basically I have a solution to change the query to make table and after adding Autonumber, but maybe the best would be if the query would be able to do it?

thanks,
0
Comment
Question by:csehz
6 Comments
 
LVL 20

Assisted Solution

by:clarkscott
clarkscott earned 50 total points
ID: 36598941
You can use the autonumber in a query for sorting/viewing purposes, but you cannot actually add a value to it in an append query.

You would use a WHERE clause for the existing autonumber in your append query and not assign to a field you're adding (let the 'autonumber' function work by itself).

Scott C
0
 
LVL 14

Assisted Solution

by:Bill Ross
Bill Ross earned 50 total points
ID: 36598973
Hi csehz,

You are on the right track but you don't need an autonumber for this.  Sort the records anyway you want in the query and then use the query as the recordsource of your form (or report) whenever you need it.

In MS Access select queries and tables work quite similarly.

Regards,

Bill
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 36598998
Keep in mind - sorting by four fields - you may want to control the 'sort within sort' order.
The sort order should be from left to right - either in a query gui or SQL query.

Scott C
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 300 total points
ID: 36600151
"is there way in Access 2000 to add an autonumber to a Query?"
No.
"change the query to make table and after adding Autonumber,"
This is what you can do:

1) Run your Make Table
2) You can now add an Auto Number field to the new table with one line of code:

'Run the MakeTable query first ...
CurrentDb.Execute "YourMakeTableName", dbFailOnError

'Create the Auto Number column
CurrentDb.Execute "ALTER TABLE YourMakeTableName ADD COLUMN ColumnName COUNTER"

where ColumnName is the name you want for the Auto Counter field.

mx
0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 100 total points
ID: 36600477
If you're looking to just include a "row number' in the query output you might be able to do something like this:

http://allenbrowne.com/ranking.html

See the "Ranking in a Query" section.
0
 
LVL 1

Author Comment

by:csehz
ID: 36707635
Thanks very much the answers, concretely I was able to execute of DatabaseMX advice in the attached database.

LSMConsulting this Ranking query is very inspirating probably yes exactly this is the name what I would like. Just my abilities.. So far was not able to create it, maybe would like to put it in a different question once
KeepOrder.mdb
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question