'Roll Back' new record on form

  • Thread starter Thread starter pedro
  • Start date Start date
P

pedro

Hi,

I have created a form for transactions with an autonumber field to generate
a transactions ID. I have received a request from users of the form to be
able to roll back a new record (in the case of data entry error) so that the
transaction ID does not commit to the database. They do not want to delete
the record as this would generate 'gaps' in the transactions ID sequence eg
1, 2, 3, 5 and so on.

Any macro or code that would make this happen?

cheers
 
hi Pedro,
I have created a form for transactions with an autonumber field to generate
a transactions ID. I have received a request from users of the form to be
able to roll back a new record (in the case of data entry error) so that the
transaction ID does not commit to the database. They do not want to delete
the record as this would generate 'gaps' in the transactions ID sequence eg
1, 2, 3, 5 and so on.
This is not possible with an AutoIncrement field due to its nature as it
only guarantees a value greater than the last one.

You need to evalutate your ID before saving the recordset:

Nz(DMax("TransactionID", "yourTable"), 0) + 1


mfG
--> stefan <--
 
Thanks Stefan,

Not sure what you mean by 'evaluate' the ID field - I assume the code adds
one to the previous ID (this would replace an auto number field?)

cheers
 
hi Pedro,
Not sure what you mean by 'evaluate' the ID field - I assume the code adds
one to the previous ID (this would replace an auto number field?)
Yes, that's correct. Use it in the BeforeUpdate event of your Form:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me![TransactionID] = Nz(DMax("TransactionID", "yourTable"), 0) + 1

End Sub



mfG
--> stefan <--
 
Back
Top