Solved

How not show records on a form bound to a table

Posted on 2014-10-16
4
139 Views
Last Modified: 2014-10-17
I have a form which is bound to a table.  Some of the records in the table do not have data in the field named "Description"  If there is nothing in the description field I do not want those records to show in the form (continuous form by default).

I thought I could do it with in the onopen event of the form but this doesn't work:

    Me.Filter = [Description] <> "*"
    Me.FilterOn = True
0
Comment
Question by:SteveL13
  • 2
  • 2
4 Comments
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
ID: 40385303
Change the form's RecordSource query to include criteria so the records are never retrieved.

Select ..
From ..
Where Description & "" <> "";

I could have said:
Where Not (Description Is Null) AND Not (Description = "")
but the first expression handles both nulls and ZLS and is easier to understand.  Compound negatives can get confusing.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 250 total points
ID: 40385378
This should do it:

     Me.Filter = "[Description] Is Not Null"
     Me.FilterOn = True

/gustav
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40385652
Gus,
That assumes the Description is null.  It may be a ZLS which is indistinguishable visually.  In most cases, I do not allow ZLS in my tables.  They cause nothing but confusion and extra work.  It is only imports from other applications that may include them and only in staging tables.

A common way to get a ZLS in a text field that isn't set to prevent them is via a form.  If the user enters a value in a text field and then changes his mind and uses the backspace to get rid of the typing, a ZLS is saved in the field rather than null.  Access knows the field was dirtied but is now empty so it saves a ZLS.  Of course, you would get an error on save if the table does not allow ZLS.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40386113
>  I do not allow ZLS in my tables.

Neither do I, and you have to actively select it. In most cases, if it is allowed, it's by an error.
That's why my filter string should do it; the wording is carefully selected.

/gustav
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now