Wildcards

Novice1

Registered User.
Local time
Today, 00:30
Joined
Mar 9, 2004
Messages
385
I'm writing an If ... then statement but I'm unsure how to write a wildcard in VBA. I want to identify if someone has an @ sign in the field.

If Me.FieldName = "*@*" Then ...

Since I'm checking for an e-mail address, I have characters before and after the AT sign (@). What is the proper signature for multiple wildcards before and after the AT sign?

Thanks in advance.
 
That should grab anything on either side...
 
Check the Access help files for the Like Operator.
 
If all you are doing is checking for the existance of an "@" sign and that there are characters before and after you can check as follows:

Code:
Dim aEMAIL as Variant
Dim sEMAIL as String

sEMAIL=Me.FieldName

aEMIAL=Split(sEMAIL,"@")

If Ubound(aEMAIL)<>1 then
  'Invalid Email It does not contain an "@" sign or has more then one
Else
  If Len(Trim(aEMAIL(0)))>0 and Len(Trim(aEMAIL(1)))>0 Then
     'Valid Email in that it has two parts seperated by "@" and has characters 
     'in both parts
  Else
    'Invalid email in that of the two parts one or both parts contains an
    'empty string or no characters at all
  End If
End if
 

Users who are viewing this thread

Back
Top Bottom