Catching record before it saves?

T

Tofudisan

I've got a small 3-user database. The GUI is Access 2K and the data
is in an MS SQL 2005 back-end.

Today I noticed some NULL records being created in the database by the
same user. In talking to the user I found out that she would go to a
new record and then use the built-in Access "Find" (binoculars button
on the toolbar) to look for records. So I know that what is happening
is that she's creating the new record and then the Find operation is
moving off of that record thereby saving it.

My question is how to still let them have the built-in Find utility
but keep them from creating the NULL records when they move off a
"new" record? Should I just use the Before Update event to catch the
record and effectively delete it when the recordset moves off of the
record?
 
N

NetworkTrade

Essentially your issue is the Dirty status.

Search in this area on the topic of Dirty and you will see alot of dialog
with similar requirements...

or consider a redesign of the user interface to make going to a new record
less viable....
 
A

Allen Browne

Use the BeforeUpdate event procedure of the form to catch the case where all
the fields are null. Cancel the event, and then undo the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord And IsNull(Me.Surname) And IsNull(Me.FirstName) Then
Cancel = True
Me.Undo
End If
End Sub

You might also consider providing some unbound controls for finding a
record, rather than have the user attempt to use the bound text box for
multiple purposes (data entry + search.) There's an example of how to create
such a form here:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top