473,490 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using Like Nz() in Access losing records when used more then once in query

I have a query with 5 possible criteria via a form. If criteria is
not entered, I use the like Nz() function on the backend query to use
an "*" for criteria fields left blank. The query is not returning the
full recordset. If the Like Nz() function is used on 1 field, it
returns the correct number of records. As soon as I add it on more
then one field, it loses records somehow. ???

For example,
SELECT [Glossary].GlossaryID, [Glossary].CoordinatorName,
[Glossary].Status, [Glossary].MaintenanceCategory
FROM [Glossary]
WHERE ((([Glossary].CoordinatorName) Like
Nz(Forms!JenSelection!Coordinator,"*"));

This returns the correct number of fields using the function on one
field.

This below does not:
SELECT [Glossary].GlossaryTermID, [Glossary].CoordinatorName,
[Glossary].Status, [Glossary].MaintenanceCategory
FROM [Glossary]
WHERE (([Glossary].CoordinatorName) Like
Nz(Forms!JenSelection!Coordinator,"*")) And (([Glossary].Status) Like
Nz(Forms!JenSelection!Status,"*")) And
(([Glossary].MaintenanceCategory) Like
Nz(Forms!JenSelection!MaintenanceCategory"*"));
Nov 12 '05 #1
2 2580
Jennifer wrote:
I have a query with 5 possible criteria via a form. If criteria is
not entered, I use the like Nz() function on the backend query to use
an "*" for criteria fields left blank. The query is not returning the
full recordset. If the Like Nz() function is used on 1 field, it
returns the correct number of records. As soon as I add it on more
then one field, it loses records somehow. ???

For example,
SELECT [Glossary].GlossaryID, [Glossary].CoordinatorName,
[Glossary].Status, [Glossary].MaintenanceCategory
FROM [Glossary]
WHERE ((([Glossary].CoordinatorName) Like
Nz(Forms!JenSelection!Coordinator,"*"));

This returns the correct number of fields using the function on one
field.

This below does not:
SELECT [Glossary].GlossaryTermID, [Glossary].CoordinatorName,
[Glossary].Status, [Glossary].MaintenanceCategory
FROM [Glossary]
WHERE (([Glossary].CoordinatorName) Like
Nz(Forms!JenSelection!Coordinator,"*")) And (([Glossary].Status) Like
Nz(Forms!JenSelection!Status,"*")) And
(([Glossary].MaintenanceCategory) Like
Nz(Forms!JenSelection!MaintenanceCategory"*"));


So you are looking for all records where the coordinator name is null
and a status that is null and a maintenace category that is null. I
would expect your query is returning all records where those conditions
are true. Isn't that what you asked for?
Nov 12 '05 #2
Try the setting up your query using OR rather than AND
"Jennifer" <je***************@fmglobal.com> wrote in message
news:e3**************************@posting.google.c om...
I have a query with 5 possible criteria via a form. If criteria is
not entered, I use the like Nz() function on the backend query to use
an "*" for criteria fields left blank. The query is not returning the
full recordset. If the Like Nz() function is used on 1 field, it
returns the correct number of records. As soon as I add it on more
then one field, it loses records somehow. ???

For example,
SELECT [Glossary].GlossaryID, [Glossary].CoordinatorName,
[Glossary].Status, [Glossary].MaintenanceCategory
FROM [Glossary]
WHERE ((([Glossary].CoordinatorName) Like
Nz(Forms!JenSelection!Coordinator,"*"));

This returns the correct number of fields using the function on one
field.

This below does not:
SELECT [Glossary].GlossaryTermID, [Glossary].CoordinatorName,
[Glossary].Status, [Glossary].MaintenanceCategory
FROM [Glossary]
WHERE (([Glossary].CoordinatorName) Like
Nz(Forms!JenSelection!Coordinator,"*")) And (([Glossary].Status) Like
Nz(Forms!JenSelection!Status,"*")) And
(([Glossary].MaintenanceCategory) Like
Nz(Forms!JenSelection!MaintenanceCategory"*"));

Nov 12 '05 #3

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

Similar topics

4
4718
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
4
2475
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
2
2164
by: Jennifer | last post by:
I have a query with 5 possible criteria via a form. If criteria is not entered, I use the like Nz() function on the backend query to use an "*" for criteria fields left blank. The query is not...
19
4064
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
17034
by: carrionk | last post by:
Hi, I'm running an ADO Recorset from Excel to gather data from Access. Basically it's copying the records of a query -that runs without problem in Access- That query has an expression with NZ()...
42
2174
by: lylefair | last post by:
The file is now available as http://www.ffdba.com/downloads/testingNZ3.dat (rename .dat to .mdb) or http://www.ffdba.com/downloads/testingNZ3.mdb (At time of posting I have not opened the file.)
10
4557
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
2
2366
by: roz | last post by:
Hello, I'm fairly new to VB programming and I've been going round the bend with this problem, so any nudges or shoves in the right direction would be greatly appreciated. I have a template...
2
2731
by: Will | last post by:
Hi, I need to handle blank values in a query calculation. I have 636 records at the moment but when I sum over these records the blank fields are not returned. I have looked around here and on...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
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...
1
6847
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
7352
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...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.