473,396 Members | 1,886 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,396 software developers and data experts.

ignore null value when filtering with multi criteria

i have a query with 4 fields, and a form based on it. i put another 4 textbox to get criteria to filter the query. the query runs normally when all the textbox have a value (not null) but when one or more of them is empty (null) the query returns no records. how can i ignore the (null) in my criteria.
Oct 14 '06 #1
10 8336
MMcCarthy
14,534 Expert Mod 8TB
Post the full query



i have a query with 4 fields, and a form based on it. i put another 4 textbox to get criteria to filter the query. the query runs normally when all the textbox have a value (not null) but when one or more of them is empty (null) the query returns no records. how can i ignore the (null) in my criteria.
Oct 14 '06 #2
Post the full query
how can i post the query?
Oct 14 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Open the query in design view and then change the view button to show SQL. Then simply copy and paste the code here.


how can i post the query?
Oct 14 '06 #4
the query is:

SELECT Drugs.EnName, Drugs.Cmpny, Drugs.CPrice, Drugs.NPrice
FROM Drugs
WHERE (((Drugs.EnName)=[Forms]![SbQDrg]![TextA]) AND ((Drugs.Cmpny)=[Forms]![SbQDrg]![TextB]) AND ((Drugs.CPrice)=[Forms]![SbQDrg]![TextC]) AND ((Drugs.NPrice)=[Forms]![SbQDrg]![TextD]));

thanks a lot..
Oct 15 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Try pasting this instead and see if it will work:

SELECT Drugs.EnName, Drugs.Cmpny, Drugs.CPrice, Drugs.NPrice
FROM Drugs
WHERE IIf(Not IsNull([Forms]![SbQDrg]![TextA]),[Drugs].[EnName]=[Forms]![SbQDrg]![TextA] AND)
IIf(Not IsNull([Forms]![SbQDrg]![TextB]),[Drugs].[Cmpny]=[Forms]![SbQDrg]![TextB] AND)
IIf(Not IsNull([Forms]![SbQDrg]![TextC]),[Drugs].[CPrice]=[Forms]![SbQDrg]![TextC] AND)
IIf(Not IsNull([Forms]![SbQDrg]![TextD]),[Drugs].[NPrice]=[Forms]![SbQDrg]![TextD]);
Oct 15 '06 #6
sorry..
but a syntax error in it because ofthe "( " can you send it again.

thanks..thanks..thanks
Oct 15 '06 #7
Thanks..............
Oct 15 '06 #8
MMcCarthy
14,534 Expert Mod 8TB
Are you still getting an error, if so what exactly does it say?



sorry..
but a syntax error in it because ofthe "( " can you send it again.

thanks..thanks..thanks
Oct 15 '06 #9
realy i don't try it again because i found a solution using VB-code that is:

If Not IsNull(Me.txtEnName) Then
strWhere = strWhere & "([EnName] = """ & Me.txtEnName & """) AND "
End If

and so on for other criteria then:


strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
Oct 16 '06 #10
realy i don't try it again because i found a solution using VB-code that is:

If Not IsNull(Me.txtA) Then
strWhere = strWhere & "([EnName] = """ & Me.txtA & """) AND "
End If

and so on for other criteria then:
lngLen = Len(strWhere) - 5
strWhere = Left$(strWhere, lngLen)
Me.Filter = strWhere
Me.FilterOn = True
thats all.
Oct 16 '06 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: robert | last post by:
running 8.1.7 server, 8.1.6 client. i *thought* inner join should not return nulls, but not only that, but i get way more rows than i'm expecting. assume: order table: order_number
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
12
by: Gary | last post by:
Hi! guys, I have a SQL agent job fails because it gets 10 warnings when it runs a stored procedure. These warnings are trivial and can be ignored. Can I make it ignore these warnings and...
2
by: PC | last post by:
Hi, I have used the DLast("!","")function to find and display the last entry in a table. How would I go about displaying the last record in a table that is not Null? Thanks in advance ...pc
6
by: AAVF | last post by:
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...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
3
by: Simon | last post by:
Dear reader, I found out a strange behaviour in a query of the type Total (summation query). In case of a normal select query with a criteria setting Is Null for field-A, four (4) records...
10
by: nickvans | last post by:
I have a form in which users may search for a module based on a number of criteria including three check boxes (indicating which processes have been completed) as well as a text box for the user to...
0
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.