Automatic increasing value

L

LeifT

If I have a field of type Number in a table and put in "1" as a start value
and want this value to increase by "1" for each new row so I will have a form
of own numbering of each rows - How do I do ??

I have tried to write a question to be answered by the internal help in
Access but I havn´t succeeded.

Thank You in advance for help
 
D

Douglas J Steele

You can set the value in the form's BeforeUpdate event, using, say, DLookup
to find the current maximum value used, and adding one to it. If you want to
see the value before it's saved, you could put the code in the form's
Current event, and check whether or not it's a new record.
 
L

LeifT

Thank You for Your answer but I have once seen another solution - which I
sorry to say has forgotten - and this solution was something like "Count
......"
Do You know this solution
 
D

Douglas J Steele

You could create a query that returns the rowcount (SELECT Count(*) FROM
MyTable), open a recordset based on that query and check the value of
Field(0).

You could also use the DCount function (DCount("*", "MyTable"))
 

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