Question:

VBA query with Null value?

by  |  earlier

0 LIKES UnLike

I am writing a query with three fields to be checked on the form. If any of these three fields are blank, I am getting a "Invalid Use of Null" error message. I have used the Nz() function but that gives me no queried down result as it is blank. How can I skip the fields that are blank (Null) in the query?

 Tags:

   Report

1 ANSWERS


  1. You can use something like this for each field, use else if as necessary...

    If IsNull([myfield]) Then

      MsgBox ("Field cannot be blank!"), vbExclamation, "Invalid Field"

    End If

    Edit

    --------------

    For a query use:

    SELECT field1, field2, field3

    FROM table

    WHERE field1 Is Not Null AND field2 Is Not Null AND field3 Is Not Null

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.