Solved

Access 2000 - Autonumber in a Query

Posted on 2011-09-26
6
486 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now