Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2000 - Autonumber in a Query

Posted on 2011-09-26
6
Medium Priority
?
510 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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 …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

609 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