Autonumber in a query containing text field

ppataki

Registered User.
Local time
Today, 02:18
Joined
Sep 5, 2008
Messages
267
Dear All,

I have a query that has only one field and I would like to add a new field that displays the number of the record

I have managed to do this for numeric fields with the help of a subquery like this:
Code:
SELECT [Copy Of qapp_ext_cikk].Cikkszam, (SELECT Count(*)FROM [copy of qapp_ext_cikk] AS M1 WHERE [cikkszam]>[copy of qapp_ext_cikk].[cikkszam])+1 AS test
FROM [Copy Of qapp_ext_cikk];

and it works fine

My question is: how can I do this if my field is TEXT and not numeric?

Many thanks in advance
 
Thanks, but the problem is that the article is also only about numeric fields
 
Well, you could create a temporary table (TempTable) with 2 fields

fld1 Autonumber
fld2 text

Then use an append query
Code:
INSERT INTO TempTable (fld2)
SELECT [Copy Of qapp_ext_cikk].Cikkszam
FROM [Copy Of qapp_ext_cikk];

Then
Code:
SELECT fld1, fld2 from TempTable

or some variation of this depending on your circumstances.
 
This is exactly what I have done to solve this, I was just curious if that can be done with a single query instead of creating temp tables

Or maybe this can also be solved with VBA to write a function that just generates increments starting at 1 to the end of the recordset...?

Thank you!
 
It turned out that it does not work that well unfortunately
If the keyname and keyvalue are null values or the same, the function outputs same numbers or zeros :(

Any advise please?

Thx!
 

Users who are viewing this thread

Back
Top Bottom