Autonumber

G

Guest

I am using Autonumber for my primary key in a table. When I open the form the
autonumber does not increment until I put something in the 0 index box, then
the autonumber shows up in the box. I want the autonumber to show up when I
open the form up to insert the rest of the information in the form
 
A

Alex White

Hi Ed,

That is by design, try saving the record with docmd.runcommand
accmdsaverecord, see if that works otherwise you may have to create you
own counter by either getting the largest value already in the table and
adding 1 or create another table just to hold counters for each table
you want to do this with.

Hope it helps.

Regards

Alex White MCSE MCDBA
www.IntraLAN.co.uk

-----Original Message-----
From: ED [mailto:[email protected]]
Posted At: 24 April 2005 21:25
Posted To: microsoft.public.access.forms
Conversation: Autonumber
Subject: Autonumber

I am using Autonumber for my primary key in a table. When I open the
form the
autonumber does not increment until I put something in the 0 index box,
then
the autonumber shows up in the box. I want the autonumber to show up
when I
open the form up to insert the rest of the information in the form
 
S

Steve Schapel

ED,

You will have to do something to trigger the commencement of a new
record before the new Autonumber value is assigned. As you have
discovered, this is normally via the act of entry of data into the
record. You can simulate this, either by entering data into one of your
existing fields, or, more likely, into a "dummy" field which you add to
your table/form specifically for the purpose. Then, code on the Current
event of the form, something like this...
Private Sub Form_Current()
If Me.NewRecord Then
Me.Dummy = 1
End If
End Sub
 

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