apply fuction for data validation

newby2VBA

Registered User.
Local time
Today, 11:16
Joined
Feb 6, 2010
Messages
45
I have a function CheckEmailName() that works, at least in the immediate window.
Like this:
?CheckEmailName(joe@workcom)
returns msg: missing .

Wonderful but when I tried to use it on my form in the beforeupdate on the field like this it did nothing: CheckEmailName(MyField)
PS I did try it on the form with the same email address

Anyone know how I should be doing this so I get the function to return my validation msg if the
 
To use it in the before update event you either want the function to return True/False and have this in the before update event:

Cancel = CheckEmailName(joe@workcom)

Or test for the result of the function and set Cancel appropriately.
 
To use it in the before update event you either want the function to return True/False and have this in the before update event:

Cancel = CheckEmailName(joe@workcom)

Or test for the result of the function and set Cancel appropriately.


The Function returns a string Msg, not a true or false so were does that leave me?
 
Well, either change what it returns or test for it:

If CheckEmailName(joe@workcom) = "Missing" Then
Cancel = True
 
Well, either change what it returns or test for it:

If CheckEmailName(joe@workcom) = "Missing" Then
Cancel = True


This is my problem I should of explained better...
What it returns is what I want to display as a msg if the user does not enter the email address correctly, otherwise it will return nothing which is perfect since it meet the criteria I want.
 

Users who are viewing this thread

Back
Top Bottom