Adding Autonumber columns into a Query Result

  • Follow


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?

0
Reply mezzanine1974 3/27/2007 11:33:36 AM

hi,

mezzanine1974 wrote:
> 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 <--
0
Reply Stefan 3/27/2007 11:54:13 AM

1 Replies
4439 Views

(page loaded in 0.041 seconds)


Reply: