Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closing a bound form without saving changes

Tags:

vba

ms-access

Quick question here, hoping for a concise sensible solution.

I have a bound form purely for data entry (cannot browse records, only insert them). I will have a lot of users that screw up. To avoid dirty data, I want them to confirm that the form is correct before submitting the record.

Problem is, as soon as I input ANYTHING on the form, access creates and saves a record.

I want the record to ONLY be saved and committed if the user clicks 'Submit'. If they click close or exit the application, I do not want that partially completed record in the database.

Without using an unbound form and calling an insert function, is there a simple solution?

like image 421
Scotch Avatar asked Jan 03 '13 20:01

Scotch


Video Answer


1 Answers

An autonumber is there to be unique, not sequential. If you need a sequential number, do not use autonumber. Autonumber should never be shown to the user. It can never be relied upon to be anything but unique, and if you mess about enough, not even that.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.AText = "Invalid" Then
    Me.Undo
    Cancel = True
End If
End Sub

Note that a form with a subform may not work with undo, because the record is committed on change from the subform to the main form and vice versa and it all gets quite complicated.

like image 170
Fionnuala Avatar answered Sep 28 '22 18:09

Fionnuala