Solved How to clear captured record from MS Access (1 Viewer)

nector

Member
Local time
Today, 02:05
Joined
Jan 21, 2020
Messages
368
I want to clear the input form so that new record can be added, I'm using this code below, but it's creating a new PK number, this is leaving some gaps in sequencing my record and it's an audit issue because it's not always when people should continue capturing at some point they have to knock off.

Code:
DoCmd.GoToRecord , , acNewRec
 

LarryE

Active member
Local time
Yesterday, 16:05
Joined
Aug 18, 2021
Messages
592
PK sequencing gaps are common (ingore them). PK's mean nothing to any user. They are only used by ACCESS itself to keep track of records. No PK number should ever be visible to any user anyway.

Use other means to validate data input.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:05
Joined
Oct 29, 2018
Messages
21,474
Also, just moving the form to a new record shouldn't generate a new pk unless you're dirtying the form using code. What do you have in the Current event?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:05
Joined
Feb 28, 2001
Messages
27,189
LarryE's point bears emphasis. Under NO CIRCUMSTANCES should an auto-number PK have ANY REAL-WORLD MEANING. To use it for audit continuity is contrary to its nature. An auto-number field has no business having any meaning. Well,... almost none. I sometimes use it as an after-the-fact "confirmation number" - but a random number or a hash-key could have been just as easily used in that context. The point is that the ONLY thing you CAN rely on regarding auto-numbers is UNIQUENESS. You cannot rely on CONTIGUITY. Actually, you cannot even rely on ORDER, since if you are sharing a back-end and two users come in to add records that include an auto-number PK and a time-stamp, it would be possible for the record to sort in two different orders based on that PK and the timestamp. The auto-number is defined when the new record gets dirty but the timestamp can be defined in a different order depending on the design of a form, particularly if it depends on a specific user action.
 

Users who are viewing this thread

Top Bottom