Preventing accidental record creation

  • Thread starter Thread starter David Gartrell
  • Start date Start date
D

David Gartrell

Hi there,

I wonder if someone could help me.

I've got an Access 2000 database which is accessed by several users.
Basically i've got a form attached to a simple name and address table which
allows the user to type in a new name and address. The problem i've got is
that if 'page down' is accidentally pressed or the wheel on the mouse is
used then a new record will appear even though the first one is incomplete.
most people who use it would notice this and return to the previous record.
However we're also going to be using temporary staff too at some point who
may not notice (or even worse may not care) and this could potentially cause
a problem with data accuracy. So the question is: is there a way of
locking the form to the record so that another isn't inadvertently created
by the accidental use of 'Page Down' or using the mouse wheel.

I'd be very grateful for any help you are able to give.

Many thanks

David.
 
Incidentally i've set the 'Data Entry' property for the form to YES which
prevents the possibility of going backwards to old records, but of course
doesn't prevent creating new records.
 
Before Access saves the record, it fires the BeforeUpdate event of the form.
Use this event to check and warn the user if things look incomplete.

This example assumes that field City is one of the latter ones on the form,
and should normally be expected to have a value.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.City) And Me.NewRecord Then
If MsgBox("Is this record complete?", vbYesNo + vbDefaultButton2) =
vbNo Then
Cancel = True
End If
End If
End Sub
 
Back
Top