Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation rule (is not null) 1

Status
Not open for further replies.

djeeten

Programmer
Mar 13, 2003
59
BE
Hi,

on this particular form, certain fields have to be filled in:

--------------
CustomerName
...
Group
Password
--------------

The form is based on the table tblCustomer and Required is set to True for those 3 fields. For those 3 fields I also set the validation rule to: 'Is Not Null' (both in the table and on the form).

I would like to know if it is possible to show the validation text if those 3 fields do not have a default value in the table (because they shouldn't).

The validation text is not shown now if for example the password is not filled in. When I try to save the record (by clicking a button) Access does generate an error in a meesage box(error after saving), but not very tactfully. I can change this error, but I can only make it 'global', for example: 'Fill in all required fields').

So, if there should be someone who can help me with the validation rule (or maybe tell me how I can change the error after saving the record in a nicer way, I would be very grateful.

Thanks in advance,

dj
 
When you enter the validation rule in the table the field below lets you key in text to be displayed if it fails, but I don't think this is very flexible. You could use
Code:
If IsNull(CustomerName) Then
    MsgBox "Customer name must be entered", vbOkOnly,
           "Missing Data"
    CustomerName.SetFocus
End If
in the CustomerName_BeforeUpdate event. I think you could also use a Select/Case group to check CustomerName/Group/Password all at the same time in the Form_BeforeUpdate event and set Cancel = True so that it doesn't try to save the record?
PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top