How Do I delete

B

bladelock

I have a form with 4 fields: txtUser, txtDesc, txtNum, UserID
When the form comes up, it displays a blank record for input and a disable
text (can't over write this) field already assigned a number (UserID). Here
is my problem, if he user does not enter any information a record is created
because of the (UserID) and saved. Even if the user hits the "Add a record"
the (UserID) is created and saved if they don't enter the 3 fields. How can I
delete this record if the user leaves the form without entering data for all
3 fields? I don't want to make the 3 fields required fields, it screws
everything up. PS, The only way to exit the form is by a command button.
Thanks all.
 
L

Larry Linson

Put VBA code in the BeforeUpdate event of the Form to check that the minimum
necessary information has been entered. If it has not, set the Cancel
argument to True -- which will cancel the update, and take whatever other
actions you think necessary to inform the user.

Best thing to do, however, is to determine why the ID field is being created
when it is -- there might be a good reason, but it might be that this can be
changed. It clearly is the root cause of your problem.

Larry Linson
Microsoft Access MVP
 
H

Heather Vernon

You can also set the fields to required in the table design view, so that
Access won't allow the records to be added unless everything has a value.
 
Top