473,473 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get 0 When There is No Value

I have the following crosstab query. Can any one tell me how to get 0 for
Daval when their is no value for that Value field.

PARAMETERS [Enter Number Of Summary Years] Short;
TRANSFORM
First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],[CountOfPatientID
])) AS DaVal
SELECT Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e AS [Screening
Partner]
FROM Tbl5YrSummaryColumns, Qry5YrSummaryNumberOfScreeningsPerYear INNER JOIN
Qry5YrSummaryNumberOfPatientsScreenedPerYear ON
Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoID =
Qry5YrSummaryNumberOfPatientsScreenedPerYear.Scree nCoID
WHERE
(((IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[Scre
enDateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear])
& " " & [FldName]) Between Year(Date())+1-[Enter Number Of Summary Years]
And Year(Date())+1))
GROUP BY Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e
ORDER BY
IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD
ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) &
" " & [FldName] DESC
PIVOT
IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD
ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) &
" " & [FldName];

Thanks!

Paula

Nov 13 '05 #1
6 1226
Paula wrote:
I have the following crosstab query. Can any one tell me how to get 0 for
Daval when their is no value for that Value field.


I might change it to

First(IIf([FldName]="Screenings",
NZ([CountOfScreenLogisticID],0),NZ([CountOfPatientID],0)))
Nov 13 '05 #2
Try:
Val(Nz(First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],
[CountOfPatientID])),0) ) AS DaVal

Are you using a Tbl5YrSummaryColumns with just two records? Are you getting
this to work the way you need?

--
Duane Hookom
MS Access MVP
"Paula" <pm*****@notmymail.com> wrote in message
news:3f*****************@newsread2.news.atl.earthl ink.net...
I have the following crosstab query. Can any one tell me how to get 0 for
Daval when their is no value for that Value field.

PARAMETERS [Enter Number Of Summary Years] Short;
TRANSFORM
First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],[CountOfPatientID ])) AS DaVal
SELECT Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e AS [Screening
Partner]
FROM Tbl5YrSummaryColumns, Qry5YrSummaryNumberOfScreeningsPerYear INNER JOIN Qry5YrSummaryNumberOfPatientsScreenedPerYear ON
Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoID =
Qry5YrSummaryNumberOfPatientsScreenedPerYear.Scree nCoID
WHERE
(((IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[Scre enDateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) & " " & [FldName]) Between Year(Date())+1-[Enter Number Of Summary Years]
And Year(Date())+1))
GROUP BY Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e
ORDER BY
IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) & " " & [FldName] DESC
PIVOT
IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) & " " & [FldName];

Thanks!

Paula

Nov 13 '05 #3
Thank you for responding!

I tried that abd also surrounding the whole First statement before I posted
and still got no zeroes.

Paula

BTW, I prefer French over Oil and Vinegar!
"Salad" <oi*@vinegar.com> wrote in message
news:Ai*****************@newsread3.news.pas.earthl ink.net...
Paula wrote:
I have the following crosstab query. Can any one tell me how to get 0 for Daval when their is no value for that Value field.


I might change it to

First(IIf([FldName]="Screenings",
NZ([CountOfScreenLogisticID],0),NZ([CountOfPatientID],0)))

Nov 13 '05 #4
Thanks, Duane, that's it!!!

Yes, the crosstab is working fine! I get the number of years(columns) that I
enter in the parameter and I get Total Screenings and Total Screened (two
fields in Tbl5YrSummaryColumns) for each year. (Did you post this technique
not too long ago?)

Some things that make me uneasy though:
1. I had to use two separate totals queries to get CountOfScreenLogisticID
and CountOfPatientID then join these queries in the crosstab and use the
First function to make it all work. I tried just including the tables needed
to get ScreenLogisticID and PatientID then using Count in the crosstab but
that did not give the correct results.
2. As you might have noticed, I had to use Year(Date())+1 to get the Year
of the current date
3. No matter what order I used for the columns in the crosstab or what
order I put CountOfScreenLogisticID and CountOfPatientID in the expression,
Total Screened (CountOfPatientID) always came first in the crosstab results.

Any ideas on the above?

I really appreciate your help getting the zeroes!

Paula

"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
news:#7**************@TK2MSFTNGP14.phx.gbl...
Try:
Val(Nz(First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],
[CountOfPatientID])),0) ) AS DaVal

Are you using a Tbl5YrSummaryColumns with just two records? Are you getting this to work the way you need?

--
Duane Hookom
MS Access MVP
"Paula" <pm*****@notmymail.com> wrote in message
news:3f*****************@newsread2.news.atl.earthl ink.net...
I have the following crosstab query. Can any one tell me how to get 0 for Daval when their is no value for that Value field.

PARAMETERS [Enter Number Of Summary Years] Short;
TRANSFORM

First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],[CountOfPatientID
])) AS DaVal
SELECT Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e AS [Screening
Partner]
FROM Tbl5YrSummaryColumns, Qry5YrSummaryNumberOfScreeningsPerYear INNER

JOIN
Qry5YrSummaryNumberOfPatientsScreenedPerYear ON
Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoID =
Qry5YrSummaryNumberOfPatientsScreenedPerYear.Scree nCoID
WHERE

(((IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[Scre

enDateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear])
& " " & [FldName]) Between Year(Date())+1-[Enter Number Of Summary Years] And Year(Date())+1))
GROUP BY Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e
ORDER BY

IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD
ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) &
" " & [FldName] DESC
PIVOT

IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD

ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear]) &
" " & [FldName];

Thanks!

Paula


Nov 13 '05 #5
See Duane Hookum's response!

Paula
"Salad" <oi*@vinegar.com> wrote in message
news:Ai*****************@newsread3.news.pas.earthl ink.net...
Paula wrote:
I have the following crosstab query. Can any one tell me how to get 0 for Daval when their is no value for that Value field.


I might change it to

First(IIf([FldName]="Screenings",
NZ([CountOfScreenLogisticID],0),NZ([CountOfPatientID],0)))

Nov 13 '05 #6
I might have been the OP of the cartesian crosstab with the table with two
records.
1) using First() in a crosstab often works very well
3) Total Screened comes before Total Screenings in alpha order.

--
Duane Hookom
MS Access MVP
"Paula" <pm*****@notmymail.com> wrote in message
news:AI*****************@newsread2.news.atl.earthl ink.net...
Thanks, Duane, that's it!!!

Yes, the crosstab is working fine! I get the number of years(columns) that I enter in the parameter and I get Total Screenings and Total Screened (two
fields in Tbl5YrSummaryColumns) for each year. (Did you post this technique not too long ago?)

Some things that make me uneasy though:
1. I had to use two separate totals queries to get CountOfScreenLogisticID and CountOfPatientID then join these queries in the crosstab and use the
First function to make it all work. I tried just including the tables needed to get ScreenLogisticID and PatientID then using Count in the crosstab but
that did not give the correct results.
2. As you might have noticed, I had to use Year(Date())+1 to get the Year
of the current date
3. No matter what order I used for the columns in the crosstab or what
order I put CountOfScreenLogisticID and CountOfPatientID in the expression, Total Screened (CountOfPatientID) always came first in the crosstab results.
Any ideas on the above?

I really appreciate your help getting the zeroes!

Paula

"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
news:#7**************@TK2MSFTNGP14.phx.gbl...
Try:
Val(Nz(First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],
[CountOfPatientID])),0) ) AS DaVal

Are you using a Tbl5YrSummaryColumns with just two records? Are you

getting
this to work the way you need?

--
Duane Hookom
MS Access MVP
"Paula" <pm*****@notmymail.com> wrote in message
news:3f*****************@newsread2.news.atl.earthl ink.net...
I have the following crosstab query. Can any one tell me how to get 0 for Daval when their is no value for that Value field.

PARAMETERS [Enter Number Of Summary Years] Short;
TRANSFORM

First(IIf([FldName]="Screenings",[CountOfScreenLogisticID],[CountOfPatientID
])) AS DaVal
SELECT Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e AS [Screening Partner]
FROM Tbl5YrSummaryColumns, Qry5YrSummaryNumberOfScreeningsPerYear INNER
JOIN
Qry5YrSummaryNumberOfPatientsScreenedPerYear ON
Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoID =
Qry5YrSummaryNumberOfPatientsScreenedPerYear.Scree nCoID
WHERE

(((IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[Scre

enDateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear])
& " " & [FldName]) Between Year(Date())+1-[Enter Number Of Summary Years] And Year(Date())+1))
GROUP BY Qry5YrSummaryNumberOfScreeningsPerYear.ScreenCoNam e
ORDER BY

IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD
ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear])
&
" " & [FldName] DESC
PIVOT

IIf([FldName]="Screenings",[Qry5YrSummaryNumberOfScreeningsPerYear].[ScreenD

ateYear],[Qry5YrSummaryNumberOfPatientsScreenedPerYear].[ScreenDateYear])
&
" " & [FldName];

Thanks!

Paula



Nov 13 '05 #7

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

Similar topics

3
by: Rupa | last post by:
Hi, I'm trying to write an xslt to convert an email in xml format to a new xml format. <descr> <xsl:choose> <xsl:value-of select="body"> </xsl:value-of select> <xsl:when test=" <xsl:value-of...
3
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form...
4
by: D Witherspoon | last post by:
I have a Structure I have created and am using it as a Public Property of a class. Here is the property. ------------------------------------------------------ Dim _MyID As SInteger Public...
2
by: Joey | last post by:
Hi There, I am trying to get the selected value of a listbox when I click a button, everything works ok and I can bind the list and when I have a basic page and click a button to invoke a sub it...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
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
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...

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.