required field

  • Thread starter Thread starter Bill H.
  • Start date Start date
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.
 
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.
 
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]
 
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.

:-(

 
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]
 
Back
Top