Required field with deleted data

G

Guest

Hi,
I have a one field continuous form that gets its data from a one-field
table. The field is unique and required. The form also has a command
“Close†button. I really have problems with the “On Event†order of things.
If a person goes to a new record and starts to enter data and then deletes
it by using the backspace or delete key and then leaves the record by 1)
clicking on another record, 2) clicking on the “Close†button or 3) presses
the “Enter†key. I get the Access error message because the field is
required.
If the new record is blank, I want to prevent the error message and remove
the blank new record based on how the user leaves the field using any one of
the above options.
How do I cover the 3 possible exit options?
Thanks
 
G

Guest

You could try using the BeforeUpdate event of the control on your form to
trap for a null value or a zero length string like;

Private Sub ControlName_BeforeUpdate (Cancel As Integer)

If IsNull (Me.ControlName) Or Me.ControlName = "" Then

Cancel = True

End If

End Sub
 

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