?
Solved

Access 2000 - Autonumber in a Query

Posted on 2011-09-26
6
Medium Priority
?
504 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 20

Assisted Solution

by:clarkscott
clarkscott earned 200 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 200 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1200 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 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 400 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

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 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