Empty Field

Lyncroft

QPR for ever
Local time
Today, 22:15
Joined
May 18, 2002
Messages
168
I've this code that automatically puts adds "Mailto" to the email address. When I delete the address it leaves the "Mailto" in the field. Can I get the field to be completely empty if I delete the email address.

Private Sub Email_Exit(Cancel As Integer)
If Not IsNull(Email) And Left$(Email.Text, 7) <> "mailto:" Then
Email.Text = "mailto:" & Email.Text
Else: IsNull (Email)
End If

End Sub
 
I not too confident on these null values, but I think all you are doing on your else clause is returning 'true' (email is null).

I think all you need is:

Else: email = ""
 
Thanks for that Peter - the "mailto" still appears. I guess it's not a major issue. It'll just have to stay there!
 
Code:
Private Sub Email_Exit(Cancel As Integer) 

If Not IsNull(Email) And Left$(Email.Text, 7) <> "mailto:" Then 
   Email.Text = "mailto:" & Email.Text 
Else
   Email = vbNullString 
End If 

End Sub
 

Users who are viewing this thread

Back
Top Bottom