Require entry of data in a control on a form

K

Karen

The form is a front end for editing an existing record and I need to
require the entry of data in a control on the form. I have tried 'is
not null' in the Validation Rule on the Properties for the control but
I can tab right on past the control and don't get an error.

I don't want to change the table to require entry because I don't want
to have to go back and fill in something for all of the existing
records in the table. The requirement of this data is new, it was
optional until now.

What am I missing?

Karen S
 
A

Allen Browne

Use the BeforeUpate event procedure of the *form* (not control.) Like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.[NameOfYourControlHere]) Then
Cancel = True 'this prevents the record being saved.
Msgbox "Oops: you forgot What'sItsName."
End If
End Sub

BTW, you can change the table. When you save the change, Access asks if you
want to check existing records, and you can answer No.
 

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