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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing to see if a field has a value

Status
Not open for further replies.
Jul 18, 2001
13
US
I've got a form field (Email) which will not always contain a value. I need to use this field to generate a hyperlink in VBA. It works fine when it contains a value, but when it has no value (No Email address) it pops up an error dialog. I've tried the Access VB reference, and find nothing to test if an expression has a value. Here is my code so far:

Private Sub Form_Open(Cancel As Integer)
Dim Address As String
If (Me.Email.Value = "*") Then
Address = "mailto:" + Me.Email.Value
Else
Address = "mailto:Default@hotmail.com"
End If
Me.sendmail.HyperlinkAddress = Address
End Sub

I'm used to PERL where you just say if ($Email), but alas, this doesn't work in VBA.

Thanks, Joe


 
If you changs it slightly to read:

If IsNull(Me.Email) Then
Whatever you want to happen when theres nothing in there.

I think this this should work for you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top