469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Showing the Autonumber on a form

Hello all,

I'm designing a incident reporting program that allows our security
department to record incidents. The problem i'm having is on a form,
when ever a user is going to add a new incident, the user will click a
new records button (which I created using a wizard). I need the
autonumber to appear automatically when ever the new record button is
clicked to add a new record. I do realize that I shouldnt use the
autonumber as a reference, but I didnt know this until I was almost
done with the project. Is their a way to do this ?

Nov 13 '05 #1
5 18072
If your autonumber is in the recordsource, all you need to do is add a
textbox to your form and set its control source to the autonumber field.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"ndn_24_7" <nd******@yahoo.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
Hello all,

I'm designing a incident reporting program that allows our security
department to record incidents. The problem i'm having is on a form,
when ever a user is going to add a new incident, the user will click a
new records button (which I created using a wizard). I need the
autonumber to appear automatically when ever the new record button is
clicked to add a new record. I do realize that I shouldnt use the
autonumber as a reference, but I didnt know this until I was almost
done with the project. Is their a way to do this ?

Nov 13 '05 #2
Tried to do this, number still not coming up when new record is
pressed. ANy other advice

Nov 13 '05 #3
The autonumber is not assigned in a new record until you make an entry in
one of the fields on the form. You can "anticipate" the autonumber by adding
an unbound textbox (not autonumber textbox) to the form and putting the
following code in the Form's OnCurrent event:
If Me.NewRecord Then
Me!NameOfTextBox = DMax("[NameOfAutoNumberField]","NameOfYourTable") + 1
Else
Me!NameOfTextBox = Me!NameOfAutoNumberTextBox
End If

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"ndn_24_7" <nd******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Tried to do this, number still not coming up when new record is
pressed. ANy other advice

Nov 13 '05 #4
"ndn_24_7" <nd******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Tried to do this, number still not coming up when new record is
pressed. ANy other advice


Since you used the wizard to write the code, I guess the instruction is
"take me to a new blank record". If this is the case and the code works,
you will simply see a new blank form. The autonumber will not get allocated
until you start to fill in the form. So one possible solution is to write
code to start to fill in the form, e.g. Me.txtDate = Date so today's date is
filled in, the form becomes "dirty" and the autonumber is allocated.
However, although you have an autonumber allocated, the user may not fill in
a required field, so the record does not get saved and that autonumber gets
lost forever. There could be other solutions - it depends how much coding
you want/are able to do.
Nov 13 '05 #5
You are already experiencing one of the problems of making the content of an
Autonumber field visible to a human. If you press on to make use of the
autonumber in this way and build on it you'll probably work yourself into
greater problems. You're better to restrict use of the autonumber datatype
to its intended purpose: the generation of unique keys.

If you need to show your users a sequential key, generate and manage it
yourself. Be aware that, in time. your autonumber field may generate
numbers with broken sequence.

HTH
--
-Larry-
--

"ndn_24_7" <nd******@yahoo.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
Hello all,

I'm designing a incident reporting program that allows our security
department to record incidents. The problem i'm having is on a form,
when ever a user is going to add a new incident, the user will click a
new records button (which I created using a wizard). I need the
autonumber to appear automatically when ever the new record button is
clicked to add a new record. I do realize that I shouldnt use the
autonumber as a reference, but I didnt know this until I was almost
done with the project. Is their a way to do this ?

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Terrance | last post: by
2 posts views Thread by Billy Greening | last post: by
2 posts views Thread by Ant | last post: by
5 posts views Thread by Jerry Spence1 | last post: by
7 posts views Thread by =?Utf-8?B?TWF0dA==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.