By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,869 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,869 IT Pros & Developers. It's quick & easy.

Showing the Autonumber on a form

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
Tried to do this, number still not coming up when new record is
pressed. ANy other advice

Nov 13 '05 #3

P: n/a
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

P: n/a
"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

P: n/a
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.