Adding Autonumber columns into a Query Result

M

mezzanine1974

I searched the group message and i found a function below to create a
AutoNumber column for a Query result.

Creating an AutoNumber field from code
http://www.mvps.org/access/tables/tbl0016.htm

I dont know how i can run this code in my Query.

Name of the Query : Q1
Field Name: Quantities

I would like to have additional column named ID which will be produced
by this code.

Can you help me?
 
S

Stefan Hoffmann

hi,
I searched the group message and i found a function below to create a
AutoNumber column for a Query result.
Creating an AutoNumber field from code
http://www.mvps.org/access/tables/tbl0016.htm
You can't use it, cause it is used to create a field in a table.
I dont know how i can run this code in my Query.
You need a key to order, then you can use this:

SELECT *, (
SELECT Count(*)
FROM QuerySource I
WHERE I.Key < O.Key
) AS ID
FROM QuerySource O
ORDER BY Key

You may use the DCount() function instead of the subselect:

ID: DCount("*";"QuerySource";"Key<" & Key)


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top