Connecting Tech Pros Worldwide Forums | Help | Site Map

Showing the Autonumber on a form

ndn_24_7
Guest
 
Posts: n/a
#1: Nov 13 '05
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 ?


PC Datasheet
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Showing the Autonumber on a form


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
resource@pcdatasheet.com
www.pcdatasheet.com


"ndn_24_7" <ndn_24_7@yahoo.com> wrote in message
news:1105385781.163241.87260@c13g2000cwb.googlegro ups.com...[color=blue]
> 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 ?
>[/color]


ndn_24_7
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Showing the Autonumber on a form


Tried to do this, number still not coming up when new record is
pressed. ANy other advice

PC Datasheet
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Showing the Autonumber on a form


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
resource@pcdatasheet.com
www.pcdatasheet.com


"ndn_24_7" <ndn_24_7@yahoo.com> wrote in message
news:1105389460.711765.156840@f14g2000cwb.googlegr oups.com...[color=blue]
> Tried to do this, number still not coming up when new record is
> pressed. ANy other advice
>[/color]


Eric Schittlipz
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Showing the Autonumber on a form


"ndn_24_7" <ndn_24_7@yahoo.com> wrote in message
news:1105389460.711765.156840@f14g2000cwb.googlegr oups.com...[color=blue]
> Tried to do this, number still not coming up when new record is
> pressed. ANy other advice[/color]

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.


Larry Daugherty
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Showing the Autonumber on a form


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" <ndn_24_7@yahoo.com> wrote in message
news:1105385781.163241.87260@c13g2000cwb.googlegro ups.com...[color=blue]
> 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 ?
>[/color]


Closed Thread


Similar Microsoft Access / VBA bytes