required field

B

Bill H.

How to I make a field on a form be required?

IOW, not let the user leave the form until the field(s) are filled in.

Thx.
 
M

Marshall Barton

Bill said:
How to I make a field on a form be required?

IOW, not let the user leave the form until the field(s) are filled in.


Either set the field in the table Required or use the form's
BeforeUpdate event to check the field and set Cancel = True
if it's not filled in.

You may want to reconsider this requirement. Users are
notoriously clever about sticking junk in fields when they
don't know the real value. Usually, a warning is
sufficient, but sometimes a utility to select records with a
missing value can also be helpful.
 
J

John W. Vinson

How to I make a field on a form be required?

IOW, not let the user leave the form until the field(s) are filled in.

Use the form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me!controlname) Then
MsgBox "Please fill in the whateveritis"
Me!controlname.SetFocus
Cancel = True
End If
End Sub


John W. Vinson [MVP]
 
B

Bill H.

That's what I've been trying to get to work, but it doesn't.

What happens is that if, on a new record, the field is left blank, Access
goes merrily on its way without pausing to tell the user the field is
required and cannot be null.

:-(

 
J

John W. Vinson

That's what I've been trying to get to work, but it doesn't.

What happens is that if, on a new record, the field is left blank, Access
goes merrily on its way without pausing to tell the user the field is
required and cannot be null.

:-(

Please post your code.

John W. Vinson [MVP]
 

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