Solved

How not show records on a form bound to a table

Posted on 2014-10-16
4
140 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 35

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 35

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

803 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