one field should not be null

G

Guest

hi everyone
I am dealing with patients sent for overseas treatment
I want some fields to be a must ( should not be blank)
Like country name and patients diagnosis i.e should not move to the next
filed without filling this field.

What code I need to do this
 
M

Marc

mhmaid said:
hi everyone
I am dealing with patients sent for overseas treatment
I want some fields to be a must ( should not be blank)
Like country name and patients diagnosis i.e should not move to the next
filed without filling this field.

What code I need to do this
Hi

If you go into the design view of the table, look at the bottom of the page.
Under the General tab are various properties that apply to the currently
selected field. If you change the Required from No to Yes, a new record
cannot be added to the database for that table without that field, and it
cannot be blanked out later without generating an error.

No coding required.
HTH
Marc
 
S

Steve Schapel

Mhmaid

In the design of the table, you can set the Validation Rule property of
these fields to:
Is Not Null
.... and enter something suitable for the Validation Text property for
the message to be displayed to the user if the condition is not met.

However, this will only be activated when the record is being saved,
which typically is when you are moving to a new record or closing the
form. If you really need for the check to be done when the user moves
from a control without entering data into that control, you will need
code on the control's exit event, for example something like this...
Private Sub Country_Exit(Cancel As Integer)
If IsNull(Me.Country) Then
MsgBox "Country required"
Cancel = True
End If
End Sub
 

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