Check if field is Null (1 Viewer)

Malkim92

Registered User.
Local time
Today, 12:53
Joined
Jun 18, 2012
Messages
15
Hey,

I have a form called AddNewCustomer which has a field called Customer_Name, now I have a button that opens another button called Command1. The thing is, when i click on that button, i need it to check if Customer_Name is empty and if it is to give an Error, and if it is not null then check if the name exists in the main table tblCustomerInformation and if it does then gives error and once a person clicks OK on the error it empties the field and if doesnt exist then open another form.

I know its much to ask, but i had a similar code saved before but i lost it.

Any help would be much appreciated.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:53
Joined
Aug 30, 2003
Messages
36,125
Here's a test for both Null and a zero length string:

If Len(Me.SomeControl & vbNullString) = 0 Then

You can use a DCount with the appropriate criteria to test if the name exists in the table:

If DCount(...) > 0 Then

http://www.mvps.org/access/general/gen0018.htm
 

Users who are viewing this thread

Top Bottom