Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Hertfordshire, England
    Posts
    78

    Question Unanswered: Checking a field for NULL or Blank

    I've got a bit of a problem where I need to check a field to see if it contains a value or not.

    I have an if statement that checks this field and if it contains a value then carries on other wise it stops with an error.

    I have tried two types of code but neither work. The first thing I tried was this:

    Code:
    If me.myTextField = "*" then
       'carry on with rest of code
    Else
       msgbox "No value in text field"
    end if
    This does not work properly. When I put no value in the text box it correctly displays my mesage box. However if I do type in a value e.g. 12345, it still displays my error message box.

    Second bit of code I tried:

    Code:
    if not me.myTextField = "" or not IsNull(me.myTextField) then   'has something
       'carry on with rest of code
    else
       msgbox "There is no value"
    end if
    This one does not work at all. It will always allow the code to continue running when there is no value in the field.

    Can anyone help solve my problem here?

    Thanks

    Neil.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    To use "*" you need to use Like. But not in vb.


    Try:
    Code:
     if NZ(me.myTextField, "") <> "" then   'has something
       'carry on with rest of code
    else
       msgbox "There is no value"
    end if
    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Sep 2003
    Location
    Hertfordshire, England
    Posts
    78
    Thanks, I will give that a try and see what happens.

  4. #4
    Join Date
    Sep 2003
    Location
    Hertfordshire, England
    Posts
    78

    Thumbs up

    It works, it works!

    Thanks very much.

Posting Permissions

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