Mandatory field

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I make a field mandatory on a form such that when a new record is
added user cannot move way until the field is filled and an appropriate
message is displayed if field is left empty?

Thanks

Regards
 
Firstly you should set the field's Required property to True (Yes) in table
design. This ensures it cannot be Null however a record is entered.

In a form you can examine the field for Null in the form's BeforeUpdate
event procedure and display a message if necessary. This procedure has a
Cancel argument, so you can also set its return value to True, e.g.

Const conMESSAGE = "A value must be entered in field whatever."

If IsNull([YourField] Then
MsgBox conMESSAGE, vbExcalamation, "Warning"
Cancel = True
End If

Ken Sheridan
Stafford, England
 
John said:
Hi

How can I make a field mandatory on a form such that when a new record is
added user cannot move way until the field is filled and an appropriate
message is displayed if field is left empty?

Thanks

Regards
 
Open your table in design view, click on the field want to make mandatory
look at the field properties box. Under the general tab you will see
"required" click yes.
 
Missed a closing parenthesis:

If IsNull([YourField]) Then

Ken Sheridan
Stafford, England

Ken Sheridan said:
Firstly you should set the field's Required property to True (Yes) in table
design. This ensures it cannot be Null however a record is entered.

In a form you can examine the field for Null in the form's BeforeUpdate
event procedure and display a message if necessary. This procedure has a
Cancel argument, so you can also set its return value to True, e.g.

Const conMESSAGE = "A value must be entered in field whatever."

If IsNull([YourField] Then
MsgBox conMESSAGE, vbExcalamation, "Warning"
Cancel = True
End If

Ken Sheridan
Stafford, England

John said:
Hi

How can I make a field mandatory on a form such that when a new record is
added user cannot move way until the field is filled and an appropriate
message is displayed if field is left empty?

Thanks

Regards
 
Back
Top