473,770 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query based report where query has no result - populate with a zero

18 New Member
I have a report with sub reports. The sub reports are query based. The queries perform a Count. Where no data exists in the table, no results are provided.

Is there a way to populate the sub report field with a 0 when this occurs?

Have tried IIF function in query with no luck.

SELECT QuoteItems.Quot eID, QuoteItems.Clea nID, QuoteItems.Cont actID, IIf(([CLeanID]) Is Null,0,Count([CleanID])) AS CountOfCleanID
FROM QuoteItems
GROUP BY QuoteItems.Quot eID, QuoteItems.Clea nID, QuoteItems.Cont actID
HAVING (((QuoteItems.Q uoteID)=[Forms]![quotation]![QuoteID]) AND ((QuoteItems.Cl eanID)=1));
Aug 27 '08 #1
3 1717
hjozinovic
167 New Member
Try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT QuoteItems.QuoteID, QuoteItems.CleanID, QuoteItems.ContactID, Count(Nz([CleanID],0)) AS CountOfCleanID
  2. FROM QuoteItems
  3. GROUP BY QuoteItems.QuoteID, QuoteItems.CleanID, QuoteItems.ContactID
  4. HAVING (((QuoteItems.QuoteID)=[Forms]![quotation]![QuoteID]) AND ((QuoteItems.CleanID)=1));
I used Nz() function instead of iif()
Aug 27 '08 #2
vljones
18 New Member
Thanks but no dice. I think the problem is in the fact that the query returns no result at all.

I am actually trying to populate a field on a sub report with a zero when the query that the sub report is based on returns no result.

Any other suggestions would be welcomed.
Aug 27 '08 #3
hjozinovic
167 New Member
Try using HasData property of your subreport for that

Expand|Select|Wrap|Line Numbers
  1. If(Me!SubRepot.Report.HasData=True,Then...,Else....)
Aug 27 '08 #4

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

Similar topics

5
3130
by: Ken Lindner | last post by:
We have a report based on a query that is called from a form. Nothing too special here. The query has 3 coulmns that are populated directly from values entered into entry fields on the form that calls the report using syntax such as "StartDate: !!" in the field value of the column. This also reads as "!! AS StartDate" in the SQL design view.
1
2074
by: Yisroel Markov | last post by:
Greetings, In Access 97 I have a subreport with two labels and a control. The record source for the control is a simple SQL query referring to another query: SELECT DISTINCTROW qryInitPositions.PortfolioNum, qryInitPositions. FROM qryInitPositions;
1
2003
by: Craig M | last post by:
Hi, I've created a query that has all calculations needed, and made a report based on this. I have then made a form based on this query. What I would like to do is print only the current record on the form. This is because the report is a "letter" and I only want 1 record per page.
5
7360
by: Randy Harris | last post by:
How can I report an average of non zero values? If the values are: 5, 0, 6, 0, 4 I would like the result 5 (15 / 3), not 3 (15 / 5) Thanks for any help...
15
4403
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows of students and columns of activities and the data are the students' scores in each activity. No problem, almost. The problem is that there are five classes at the moment and will be more classes (or courses) in future semesters. I don't want...
2
9349
by: amith.srinivas | last post by:
Hi all, From a word macro in VBA, I am trying to create a report in access DB. The report is based on a query with a parameter. I am using Set rpt = Application.CreateReport rpt.RecordSource = <<Query_Name>> Once I create the report, I m trying to create labels to display the Report title in the Report Header section.
6
4480
by: tizmagik | last post by:
I am having a lot of difficulty generating a CrossTab Query based report. I have looked online for several tutorials and whatnot but I have not been able to really find what I'm looking for, nor have I been able to adapt other people's solutions/tips to fit what I need. If anyone could please help me with the following it would be really appreciated, thank you! I need to generate a Report (say: repCrossTab) that grabs it's data from the...
5
3532
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed to 1800 stores of a national home improvement chain store. Every week I electronicaly receive an excel spreadsheet "inventory report" with 19,800 rows or records, which I import into my tblSalesData table. The table now has 10 weeks of data or...
14
3574
by: akmaRudiliyn | last post by:
Hi Everybody.. This is my firstime in creating report using microsoft access. Actually i need to build a report based on a database call Table1. I only use 2 column of databse to put in my report. 1) State 2) Status For status, i need to separate it based on value of status;
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.