making some fields mandatory in access data table

  • Thread starter Thread starter sam
  • Start date Start date
S

sam

how can I make some certain fields mandatory.

For eg. If I have a Table with Name, City, St, Zip, Address

what should i do to make Zip field mandatory?

Thanks in Advance.
 
Open the table in design view. Go to the Zip file. Set the Required property
to Yes.
 
In table design view set the Required property of that
field to Yes. As an extra precaution, and to be able to
generate a more user friendly error message, you can
use the Before Update event of your form to check the
value before the record is saved;

Private Sub Form_BeforeUdpate (Cancel As Integer)

If Nz(Me![ZipCode], vbNullString) = vbNullString Then
MsgBox "Please enter a Zip Code", vbOkOnly + vbInformation, "Incomplete"
Cancel = True
Me![ZipCode].SetFocus
End If

End Sub
 
Back
Top