|
 |
access thread: Avoid autonumber increment if cancel AddNew
Message #1 by "Steven Hendry" <hendrys4@b...> on Tue, 22 May 2001 09:37:27
|
|
When adding a new record, the Primary Key autonumber field increments by
one. This is fine if the record is saved, but if the add new record is
abandoned, the autonumber is still incremented. This means the next new
record is + 2 and so on. I would like to know how to not increment the
autonumber field unless the new record is saved, so that the next record
has
a contigeous Primary Key autonumber. This is not strictly needed, but is
"tidyer".
I have been using the example data entry from beginning visual basic
databases.
Message #2 by "Elmer Espinosa" <elmerespinosa@y...> on Tue, 22 May 2001 22:30:29 +0800
|
|
Try this one
Add a new field in your table i.e. RequestNo data type as Number
In your Command button ADD record do this c
Private Sub cmdAdd_Click()
Dim mRequest As Double ' as temporary variable
DoCmd.GoToRecord , , acLast
mRequest = [RequestNo]
DoCmd.GoToRecord , , acNewRec
[RequestNo].Value = mRequest + 1
RequestINL.SetFocus
End Sub
Instead of using your current autonumber you have to use the RecordNo filed
to increment everytime you click the add button. coz the program the
RecordNo will increment by one(1).
Elmer L. Espinosa
Programmer
PRINTMAGIC PHILIPPINES
----- Original Message -----
From: Steven Hendry <hendrys4@b...>
To: Access <access@p...>
Sent: Tuesday, May 22, 2001 9:37 AM
Subject: [access] Avoid autonumber increment if cancel AddNew
> When adding a new record, the Primary Key autonumber field increments by
> one. This is fine if the record is saved, but if the add new record is
> abandoned, the autonumber is still incremented. This means the next new
> record is + 2 and so on. I would like to know how to not increment the
> autonumber field unless the new record is saved, so that the next record
> has
> a contigeous Primary Key autonumber. This is not strictly needed, but is
> "tidyer".
>
> I have been using the example data entry from beginning visual basic
> databases.
>
Message #3 by "Elmer Espinosa" <elmerespinosa@y...> on Tue, 22 May 2001 22:47:45 +0800
|
|
----- Original Message -----
From: Elmer Espinosa <elmerespinosa@y...>
To: Access <access@p...>
Sent: Tuesday, May 22, 2001 10:30 PM
Subject: Re: [access] Avoid autonumber increment if cancel AddNew
> Try this one
>
> Add a new field in your table i.e. RequestNo data type as Number
>
> In your Command button ADD record do this c
>
> Private Sub cmdAdd_Click()
>
> Dim mRequest As Double ' as temporary variable
> DoCmd.GoToRecord , , acLast
> mRequest = [RequestNo]
> DoCmd.GoToRecord , , acNewRec
> [RequestNo].Value = mRequest + 1
> RequestINL.SetFocus
> End Sub
>
> Instead of using your current autonumber you have to use the RecordNo
filed
> to increment everytime you click the add button. coz the program the
> RecordNo will increment by one(1).
>
>
>
> Elmer L. Espinosa
> Programmer
> PRINTMAGIC PHILIPPINES
>
>
> ----- Original Message -----
> From: Steven Hendry <hendrys4@b...>
> To: Access <access@p...>
> Sent: Tuesday, May 22, 2001 9:37 AM
> Subject: [access] Avoid autonumber increment if cancel AddNew
>
>
> > When adding a new record, the Primary Key autonumber field increments by
> > one. This is fine if the record is saved, but if the add new record is
> > abandoned, the autonumber is still incremented. This means the next new
> > record is + 2 and so on. I would like to know how to not increment the
> > autonumber field unless the new record is saved, so that the next record
> > has
> > a contigeous Primary Key autonumber. This is not strictly needed, but
is
> > "tidyer".
> >
> > I have been using the example data entry from beginning visual basic
> > databases.
> >
|
|
 |