How to add AutoNumber field into a query

pafkam

New Member
Joined
Feb 1, 2008
Messages
20
I have read 15 articles but still can't figure. I have a simple query, non of the fields has unique values, and I am trying to add a field with AUtoNumber. Any help? THank you! Pavel
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Note a key phrase in that link:

Critical to creating the auto number sub-query is that the table or query you are using as a source must contain a unique index and this field must be included in your auto number query.

If you do not have one, you may be out of luck (I don't know if there is any other way to do it without this).
Why can't you add one?

Or maybe you can explain exactly what you are hoping to accomplish by doing this. What is your end goal?
There may be a different way to get there.
 
Upvote 0
Thank you. I have this (very simplified):
field1:fraction of % , field2: Total $ .
I have two rows:
1st row reads: 55% (field1), 100$ (field2)
2nd row reads: 45% (field1), 100$ (field2)
When I run field1 * field 2 I get an allocation of 55$ and 45$ in each row.
I want to add an additional autonumber field so I would assign 1 to the first row and 2 to the second row in a separate column (this will give me a unique row identifier)
 
Upvote 0
Why not just an Autonumber field to your table?

Then you will have a unique identifier which will then allow you to use that code to create query autonumber (I assume that you want it to begin with 1 each time).
 
Upvote 0
I unfortunately can not add any fields to that table. THat is why I need to use query to sort of re-create the table but with this additional unique autonumber field.
 
Upvote 0
I am afraid you may be caught in a classic "catch-22", you need the query to return a unique counter, but creating a unique counter appears to require a unique field in your query.

There is a way around that. You can create a Make Table Query to create a temporary table which contains all of the fields in your original table along with an AutoNumber field. You can then run this query you are trying to create off of this new temporary table (and make use of your new autonumber).
 
Upvote 0
I have read 15 articles but still can't figure. I have a simple query, non of the fields has unique values, and I am trying to add a field with AUtoNumber. Any help? THank you! Pavel
Hi,

Pls use create table statement as below :

create table my_table (my_column counter not null)

The above statement creates tables named my_table with 1 column my_column which is of type Autonumber (counter)

Thanks
Dhirendra
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top