473,394 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Criteria testing fields that may contain null values

Hi

We have a problem with a query.

An Access database links via ODBC to a UNIX server. To speed things, we use
the ODBC to load the relevant tables to the local PC that runs Access so
that all querying is done locally.

One of the reports we run allows the user to list all invoices within a
period. They are also allowed to select a customer code and a product set on
which to base the report. The product set comprises a Warehouse code (a
system grouping classification rather than a physical building) and a
product code. There will always be something in the field [PRODUCT_CODE],
but it is possible for the [WAREHOUSE] field to be null.

We used to run the database in Access 97, and I am pretty sure the following
criteria expression worked, in that if the user hit 'enter' when prompted
for the Warehouse, all records would be returned, including those with
'null' in the [WAREHOUSE] field. About six months ago we converted this
rather large database (c200 queries and reports) to Access 2000. Today, my
users tell me this report is ignoring records that have Warehouse value.

The criteria string used on the [WAREHOUSE] field is as follows

Like [Warehouse or enter for all] & "*"

The variable [Warehouse or enter for all] is then assigned to a created
field of its own, [WAREHOUSE_SELECTED], to show on the report.

It appears that searching using a wildcard ignores null values, but we need
to be able to pick up the nulls if the user wants all records returned.

Any ideas on how to fix this?

Regards

Tom Millington
Nov 12 '05 #1
6 5243
Try this criteria expression:

Like [Warehouse or enter for all] & "*" OR [Warehouse or enter for all] Is
Null

--
Ken Snell
<MS ACCESS MVP>

"AAVF" <tm*********@aavf.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Hi

We have a problem with a query.

An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so
that all querying is done locally.

One of the reports we run allows the user to list all invoices within a
period. They are also allowed to select a customer code and a product set on which to base the report. The product set comprises a Warehouse code (a
system grouping classification rather than a physical building) and a
product code. There will always be something in the field [PRODUCT_CODE],
but it is possible for the [WAREHOUSE] field to be null.

We used to run the database in Access 97, and I am pretty sure the following criteria expression worked, in that if the user hit 'enter' when prompted
for the Warehouse, all records would be returned, including those with
'null' in the [WAREHOUSE] field. About six months ago we converted this
rather large database (c200 queries and reports) to Access 2000. Today, my
users tell me this report is ignoring records that have Warehouse value.

The criteria string used on the [WAREHOUSE] field is as follows

Like [Warehouse or enter for all] & "*"

The variable [Warehouse or enter for all] is then assigned to a created
field of its own, [WAREHOUSE_SELECTED], to show on the report.

It appears that searching using a wildcard ignores null values, but we need to be able to pick up the nulls if the user wants all records returned.

Any ideas on how to fix this?

Regards

Tom Millington

Nov 12 '05 #2
Thanks Ken

That worked a treat.

Has something changed from A97 to A2000? I'm sure the string I was using
worked on A97.

Tom

"Ken Snell" <kt***********@notcomcast.realnet> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl...
Try this criteria expression:

Like [Warehouse or enter for all] & "*" OR [Warehouse or enter for all] Is
Null

--
Ken Snell
<MS ACCESS MVP>

"AAVF" <tm*********@aavf.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Hi

We have a problem with a query.

An Access database links via ODBC to a UNIX server. To speed things, we use
the ODBC to load the relevant tables to the local PC that runs Access so
that all querying is done locally.

One of the reports we run allows the user to list all invoices within a
period. They are also allowed to select a customer code and a product set on
which to base the report. The product set comprises a Warehouse code (a
system grouping classification rather than a physical building) and a
product code. There will always be something in the field

[PRODUCT_CODE], but it is possible for the [WAREHOUSE] field to be null.

We used to run the database in Access 97, and I am pretty sure the

following
criteria expression worked, in that if the user hit 'enter' when prompted for the Warehouse, all records would be returned, including those with
'null' in the [WAREHOUSE] field. About six months ago we converted this
rather large database (c200 queries and reports) to Access 2000. Today, my users tell me this report is ignoring records that have Warehouse value.

The criteria string used on the [WAREHOUSE] field is as follows

Like [Warehouse or enter for all] & "*"

The variable [Warehouse or enter for all] is then assigned to a created
field of its own, [WAREHOUSE_SELECTED], to show on the report.

It appears that searching using a wildcard ignores null values, but we

need
to be able to pick up the nulls if the user wants all records returned.

Any ideas on how to fix this?

Regards

Tom Millington


Nov 12 '05 #4
It shouldn't have UNLESS the fields contained zero-length strings vice null.
Nulls wouldn't match with a wildcard search, but zero-length strings (or a
series of spaces) would.

AAVF IT wrote:

Thanks Ken

That worked a treat.

Has something changed from A97 to A2000? I'm sure the string I was using
worked on A97.

Tom

"Ken Snell" <kt***********@notcomcast.realnet> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl...
Try this criteria expression:

Like [Warehouse or enter for all] & "*" OR [Warehouse or enter for all] Is
Null

--
Ken Snell
<MS ACCESS MVP>

"AAVF" <tm*********@aavf.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Hi

We have a problem with a query.

An Access database links via ODBC to a UNIX server. To speed things, we

use
the ODBC to load the relevant tables to the local PC that runs Access so
that all querying is done locally.

One of the reports we run allows the user to list all invoices within a
period. They are also allowed to select a customer code and a product set
on
which to base the report. The product set comprises a Warehouse code (a
system grouping classification rather than a physical building) and a
product code. There will always be something in the field

[PRODUCT_CODE], but it is possible for the [WAREHOUSE] field to be null.

We used to run the database in Access 97, and I am pretty sure the

following
criteria expression worked, in that if the user hit 'enter' when prompted for the Warehouse, all records would be returned, including those with
'null' in the [WAREHOUSE] field. About six months ago we converted this
rather large database (c200 queries and reports) to Access 2000. Today, my users tell me this report is ignoring records that have Warehouse value.

The criteria string used on the [WAREHOUSE] field is as follows

Like [Warehouse or enter for all] & "*"

The variable [Warehouse or enter for all] is then assigned to a created
field of its own, [WAREHOUSE_SELECTED], to show on the report.

It appears that searching using a wildcard ignores null values, but we

need
to be able to pick up the nulls if the user wants all records returned.

Any ideas on how to fix this?

Regards

Tom Millington


Nov 12 '05 #5
Thanks for the info.

I am now going through the 400+ queries in this database set to see how many
I have to modify. It looks like about 50.

One thing I have noticed. When I add the extra 'OR' statement to the
criteria and save/exit the query, when I go back into it in design view,
Access has changed the layout so that instead of having one criteria line
with the statement I entered, I now have two: one is the original, with the
'OR' statement on a second ('or') criteria line. I understand the sense in
this. However, some of these queries allow up to six variables to be
selected in the same way, all of which could come back with null-value
fields in the result. This means that when I go back into the query in
design mode, it looks like the query from hell, in that it can have a dozen
or more criteria lines. This means it is going to be a tad difficult to
maintain. Is there any way of getting Access to keep the display as I
entered it, ie one criteria line with statements containing an 'OR'
function?

Regards

Tom
"John Spencer (MVP)" <sp***********@SPAMNOT.umbc.edu> wrote in message
news:3F***************@SPAMNOT.umbc.edu...
It shouldn't have UNLESS the fields contained zero-length strings vice null. Nulls wouldn't match with a wildcard search, but zero-length strings (or a
series of spaces) would.

AAVF IT wrote:

Thanks Ken

That worked a treat.

Has something changed from A97 to A2000? I'm sure the string I was using
worked on A97.

Tom

"Ken Snell" <kt***********@notcomcast.realnet> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl...
Try this criteria expression:

Like [Warehouse or enter for all] & "*" OR [Warehouse or enter for all] Is Null

--
Ken Snell
<MS ACCESS MVP>

"AAVF" <tm*********@aavf.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
> Hi
>
> We have a problem with a query.
>
> An Access database links via ODBC to a UNIX server. To speed things, we use
> the ODBC to load the relevant tables to the local PC that runs Access so > that all querying is done locally.
>
> One of the reports we run allows the user to list all invoices within a > period. They are also allowed to select a customer code and a product
set
on
> which to base the report. The product set comprises a Warehouse code
(a > system grouping classification rather than a physical building) and a > product code. There will always be something in the field

[PRODUCT_CODE],
> but it is possible for the [WAREHOUSE] field to be null.
>
> We used to run the database in Access 97, and I am pretty sure the
following
> criteria expression worked, in that if the user hit 'enter' when

prompted
> for the Warehouse, all records would be returned, including those with > 'null' in the [WAREHOUSE] field. About six months ago we converted this > rather large database (c200 queries and reports) to Access 2000. Today, my
> users tell me this report is ignoring records that have Warehouse

value. >
> The criteria string used on the [WAREHOUSE] field is as follows
>
> Like [Warehouse or enter for all] & "*"
>
> The variable [Warehouse or enter for all] is then assigned to a created > field of its own, [WAREHOUSE_SELECTED], to show on the report.
>
> It appears that searching using a wildcard ignores null values, but we need
> to be able to pick up the nulls if the user wants all records returned. >
> Any ideas on how to fix this?
>
> Regards
>
> Tom Millington
>
>

Nov 12 '05 #6
The design view changes that you see are the normal behavior for ACCESS when
you use the Criteria expression that we provided. If you open the query in
SQL, you'll see a similar "jumble".

There is no easy way to maintain this if you want to add more fields with a
similar criterion expression. I usually resort to deleting those fields with
the criteria and recreating them with the "simple" expression.

The alternative is to not use a saved query, and instead build the SQL in
code and then run it.
--
Ken Snell
<MS ACCESS MVP>
"AAVF IT" <it***********@aavf.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
Thanks for the info.

I am now going through the 400+ queries in this database set to see how many I have to modify. It looks like about 50.

One thing I have noticed. When I add the extra 'OR' statement to the
criteria and save/exit the query, when I go back into it in design view,
Access has changed the layout so that instead of having one criteria line
with the statement I entered, I now have two: one is the original, with the 'OR' statement on a second ('or') criteria line. I understand the sense in
this. However, some of these queries allow up to six variables to be
selected in the same way, all of which could come back with null-value
fields in the result. This means that when I go back into the query in
design mode, it looks like the query from hell, in that it can have a dozen or more criteria lines. This means it is going to be a tad difficult to
maintain. Is there any way of getting Access to keep the display as I
entered it, ie one criteria line with statements containing an 'OR'
function?

Regards

Tom
"John Spencer (MVP)" <sp***********@SPAMNOT.umbc.edu> wrote in message
news:3F***************@SPAMNOT.umbc.edu...
It shouldn't have UNLESS the fields contained zero-length strings vice null.
Nulls wouldn't match with a wildcard search, but zero-length strings (or a
series of spaces) would.

AAVF IT wrote:

Thanks Ken

That worked a treat.

Has something changed from A97 to A2000? I'm sure the string I was using worked on A97.

Tom

"Ken Snell" <kt***********@notcomcast.realnet> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl...
> Try this criteria expression:
>
> Like [Warehouse or enter for all] & "*" OR [Warehouse or enter for

all] Is > Null
>
> --
> Ken Snell
> <MS ACCESS MVP>
>
> "AAVF" <tm*********@aavf.co.uk> wrote in message
> news:10***************@ananke.eclipse.net.uk...
> > Hi
> >
> > We have a problem with a query.
> >
> > An Access database links via ODBC to a UNIX server. To speed
things, we > use
> > the ODBC to load the relevant tables to the local PC that runs Access so > > that all querying is done locally.
> >
> > One of the reports we run allows the user to list all invoices within a > > period. They are also allowed to select a customer code and a product set
> on
> > which to base the report. The product set comprises a Warehouse
code
(a > > system grouping classification rather than a physical building)
and
a > > product code. There will always be something in the field
[PRODUCT_CODE],
> > but it is possible for the [WAREHOUSE] field to be null.
> >
> > We used to run the database in Access 97, and I am pretty sure the
> following
> > criteria expression worked, in that if the user hit 'enter' when
prompted
> > for the Warehouse, all records would be returned, including those with > > 'null' in the [WAREHOUSE] field. About six months ago we converted this > > rather large database (c200 queries and reports) to Access 2000. Today, my
> > users tell me this report is ignoring records that have Warehouse value. > >
> > The criteria string used on the [WAREHOUSE] field is as follows
> >
> > Like [Warehouse or enter for all] & "*"
> >
> > The variable [Warehouse or enter for all] is then assigned to a created > > field of its own, [WAREHOUSE_SELECTED], to show on the report.
> >
> > It appears that searching using a wildcard ignores null values,
but
we > need
> > to be able to pick up the nulls if the user wants all records returned. > >
> > Any ideas on how to fix this?
> >
> > Regards
> >
> > Tom Millington
> >
> >
>
>


Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
2
by: neptune | last post by:
I have a query where each customer has an or . Sometimes both fields for a customer are populated, but if is null, then will be populated and vice versa. I have a form, , where I select a...
2
by: JM | last post by:
Hello, I've created a Querydef in a Form_Load() sub. The form is a subform that no longer has linked child fields. The form is bound to this querydef. When I open the form, the fields are...
1
by: LFM | last post by:
I have a table called "employee profile" which contains a bunch of user information. In that table I have a field called "Description" which is a text/memo field. This field is not mandetory to...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
8
by: Ragbrai | last post by:
Howdy All, I have a query that is used for filtering results to be used in a combo box. The query needs to test fields from both a table and then unbound text boxes on the form that also contains...
18
by: WU10 | last post by:
Built a form based on a select query with a combo box (3 choices) in the form header which will supply a value to the query. In the query's criteria I added the following expression - !! and...
3
by: seagullino | last post by:
Hello, I've developed my first Form, a simple affair that enables the user to search text in the memo fields in our database. When the "search" button is pressed, it runs a macro which runs the...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.