Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


If NotNull then...

Posted on 2004-11-02
Medium Priority
Last Modified: 2007-12-19
I have simple search for where the user checks a check box next to the criteria that they would like to filter by.  But I was wonder if there was a way to remove the check box.  I have tried If Not IsNull but it does not work.  Here is the code that I use.

    If chkLegal = True Then
    If Nz(Forms![frm_Customer_Search]!txtLegalName, "") <> "" Then
        strWhere = "(Legal_Name LIKE '*" & Replace(Forms![frm_Customer_Search]!
        txtLegalName, "'", "''")  & "*') AND "
    End If
    End If
Question by:garland29
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 58
ID: 12472240
Hi garland29,

  Not quite sure what your asking here.  Are you saying you'd like to remove the check box (chkLegal) and just use the txtLegalName control?  

LVL 16

Expert Comment

ID: 12472332
And the where clause seems to be incomplete.

You get something like this:

strWhere = "(Legal_name Like '*yourvalue*') AND"

Author Comment

ID: 12472337
Yes I would like to remove the check box.  But there are about 8 text boxes with different criteria. I would like it to check if there is anything in the text box if not then move on.

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Expert Comment

by:Arno Koster
ID: 12472346
so you'd want to filter on a criteria if and only if the criteria is not empty ?


    returns the length of the txtLegalName field.

if len(txtLegalName) > 0 then
end if

or you could use IsEmpty( ), IsNull( ), IsNumeric( ) etc
LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 12472446

    This is the way I usually build my WHERE clauses

    Dim strCriteria

    strWhere = ""

    If Nz(Forms![frm_Customer_Search]!txtLegalName, "") <> "" Then
        strWhere  = strWhere & "Legal_Name LIKE '*' " &  Forms![frm_Customer_Search]![txtLegalName] & " AND"
   End If

   ' Next check

   ' Strip off last AND
  If Len(strWhere)>0 then strWhere =Left$(strWhere,Len(strWhere)-4))


Author Comment

ID: 12472598
I love the ones that are staring right back at me;-)  Thanks!!!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question