Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If IsNull question (simple, I think) (2000)

    I think this is a simple problem.
    I have a field called "mailto" which, when it is updated, also updates data in another field "HomeE-mail".
    I need an "IF" clause which will say that if the field "Mailto" is null, then the field [HomeE-mail] is null.

    Here is more info, in case you need it.
    The field "Mailto" is a hyperlink field and currently has an after-update event which strips the words "mailto:" off the email address in the hyperlink field "Mailto" and put the resulting value in the text field "HomeE-mail". It does this by means of some code which I earlier got from a posting on this list, I believe. Here is that current code which runs as an after-update event:

    [HomeE-mail] = Mid$([MailTo], 9, Len([MailTo]) - 9)

    That code works just fine. But sometimes I need to delete an email addresses that is in the Mailto field, so I need to add an "if" clause (something like If IsNull (mailto) Then.......) that will delete the info in the HomeE-mail field if I delete the info in the Mailto field. The current code (above) will be my Else clause.
    I have tried a few things because I thought it would be simple, but all of them result in error messages.

    Thanks in advance for any suggestions. I have had no problems with If Then when it is putting a value into something, but it seems to have me stumped when I want it to create an empty field!
    -cynthia

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If IsNull question (simple, I think) (2000)

    As you may have noticed from the code you already use, a hyperlink field doesn't behave exactly the same as a text field. In this case, you should check for an empty string:

    If [MailTo] = "" Then
    [HomeE-mail] = Null
    Else
    [HomeE-mail] = Mid$([MailTo], 9, Len([MailTo]) - 9)
    End If

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If IsNull question (simple, I think) (2000)

    Thank you! I now see that no amount of experimenting on my part would have gotten me to a workable solution - I don't know that much about the hyperlink fields yet!

    I put this code in and it appears to do just what I need.
    Thanks again.
    -cynthia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •