473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query "Where" question

Using A2K. In my table I have the field "Grant" which can have a
value or be null. I have a query that counts the number of records
and has a Where clause on the Grant field. The query won't work when
Grant is null. What's the proper syntax for getting it to work when
Grant is null?

Here's my Where criteria:

[Forms]![frmQuarterlyTrackingReport]![cboGrant]

This works fine when Grant is something other than null. If I just
push Enter when the prompt comes up, then I don't get any results when
I expect there to be some.

Thanks for any help or advice.
Nov 12 '05 #1
2 2705
Well..........since your criteria is based on a form, you could make the
user select a value before the query would run, IOW, stop the query
executing and show a message box "Please select Grant"

Or:

Use the IIF operator:
=IIF(Not IsNull([Forms]![frmQuarterlyTrackingReport]![cboGrant]),
[Forms]![frmQuarterlyTrackingReport]![cboGrant], Like "*")
-
James Lankford

"Ellen Manning" <ma**********@hotmail.com> wrote in message
news:da*************************@posting.google.co m...
Using A2K. In my table I have the field "Grant" which can have a
value or be null. I have a query that counts the number of records
and has a Where clause on the Grant field. The query won't work when
Grant is null. What's the proper syntax for getting it to work when
Grant is null?

Here's my Where criteria:

[Forms]![frmQuarterlyTrackingReport]![cboGrant]

This works fine when Grant is something other than null. If I just
push Enter when the prompt comes up, then I don't get any results when
I expect there to be some.

Thanks for any help or advice.

Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you're trying for. If the query criteria for the Grant
field is supposed to equal the value of the ComboBox "cboGrant," then
the query will only return records that have the same value as is
shown in the ComboBox. So why are you expecting the query to return
records that have a NULL in the Grant field when you are specifying
that you want records WHERE the Grant field equals the ComboBox
"cboGrant"?

If you want to count records that have NULL Grant fields you'd have to
have a criteria like this:

WHERE Grant Is Null

And that can't be accomplished by the query reading the value of a
ComboBox.

Your query has

WHERE Grant = [Forms]![frmQuarterlyTrackingReport]![cboGrant]
I'd probably set up the query in VBA to allow dynamic changes to the
WHERE clause. E.g.:

== air code ==

strSql = "SELECT * FROM <tableName> WHERE "

if isnull(Me!cboGrant) then
strWhere = " Grant Is Null "
else
strWhere = " Grant = '" & Me!cboGrant & "' "
endif

strSql = strSql & strWhere

' then use the query somehow

== end air code ==

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP57ks4echKqOuFEgEQKkqACg6LKD4MxU6q4TsePctyueHM NEoVcAoJJh
GN/cYTyXw5sAdBDPUwWR6rUm
=zUJN
-----END PGP SIGNATURE-----

Ellen Manning wrote:
Using A2K. In my table I have the field "Grant" which can have a
value or be null. I have a query that counts the number of records
and has a Where clause on the Grant field. The query won't work when
Grant is null. What's the proper syntax for getting it to work when
Grant is null?

Here's my Where criteria:

[Forms]![frmQuarterlyTrackingReport]![cboGrant]

This works fine when Grant is something other than null. If I just
push Enter when the prompt comes up, then I don't get any results when
I expect there to be some.

Thanks for any help or advice.


Nov 12 '05 #3

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

Similar topics

9
4383
by: LRW | last post by:
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or,...
2
23338
by: ITM | last post by:
Does anyone have an example of an SQL query which returns rows for the year-to-date, but where the "year" commences on August 1st? e.g. select * from mytable where datefield > last august 1st ...
5
4065
by: Rachel Weeden | last post by:
I'm working on an ASP Web application, and am having syntax issues in a WHERE statement I'm trying to write that uses the CInt Function on a field. Basically, I want to select records using...
13
2781
by: andro | last post by:
Hi everybody! I have several tables from which I want to exract the SAME value (along with other referenced data). All the values are in the same column within the tables. How can I achieve...
5
5088
by: davehansen22 | last post by:
Is there a way to generate a MySQL WHERE clause from a search string like this: "(dave OR hansen) php programmer" I would want to use the generated MySQL clause against a "memo" type field. ...
2
3446
by: santoshsri | last post by:
Hello, Is there any by which I can write a SQL to get the 4th largest salary from a table without using "join" and without using "where" clause. Suppose the table is having two columns :...
1
3344
by: itamar82 | last post by:
I am getting the following error: Microsoft OLE DB Provider for SQL Server error '80040e14' Incorrect syntax near the keyword 'WHERE'. for the sql below: SELECT TourId FROM (SELECT...
7
21966
mkremkow
by: mkremkow | last post by:
Hello all, Access 2003 Windows PC: I am trying to figure out why my Query isn't working. In this query, I want to get only those jobs that are still open and where at least one of four Yes/No...
4
11246
by: WolverYanks | last post by:
SELECT Dates., Sum(1) AS FROM Dates LEFT JOIN ON Dates. = . WHERE (((.)<)) GROUP BY Dates.; I'm doing a sports database, for entertainment and to learn Access, so hopefully this is an easy...
0
7260
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
7160
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
7384
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
7537
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
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.