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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » If IsNull question (simple, I think) (2000)

    Author
    Topic
    #370995

    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

    Viewing 0 reply threads
    Author
    Replies
    • #588421

      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

      • #588428

        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

    Viewing 0 reply threads
    Reply To: If IsNull question (simple, I think) (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: