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

NoData, but want report anyway

prn
254 Expert 100+
Hi folks,

I have a report I'm working on, with multiple subreports. Each subreport totals up various categories, working from separate queries, and the total report basically just strings the subreports together. It's possible that some of the subreports' queries will return no data, but in that case, I want the report to show zeroes for those items.

Taking one of the subreports as my test bed here, I have six items in the subreport, each of which I have (so far) filled in like so:

=Abs(Sum(([Field1]="foo") And [Field2]="bar"))

This works just fine, giving me appropriate totals of any of the permissible combinations of what I'm looking for in Field1 and Field2, including zeroes where no records with those combinations are returned by the query as long as any records at all are returned. However, if the query returns no records, all of those fields just show "#ERROR" in the report, which is less than wonderful.

On the other hand, if no records are returned, I don't need to do much counting as I know that all of the fields should be 0. My latest attempt to do this is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.     Me.Text74.SetFocus
  3.     Me.Text74.Text = "0"
  4.     Me.Text76.SetFocus
  5.     Me.Text76.Text = "0"
  6.     Me.Text78.SetFocus
  7.     Me.Text78.Text = "0"
  8.     Me.Text81.SetFocus
  9.     Me.Text81.Text = "0"
  10.     Me.Text83.SetFocus
  11.     Me.Text83.Text = "0"
  12.     Me.Text85.SetFocus
  13.     Me.Text85.Text = "0"
  14. End Sub
But this just results in a message box saying:
Expand|Select|Wrap|Line Numbers
  1. Microsoft Office Access doesn't allow you to use this method in the current view.
and when I hit the "Debug" button, the first SetFocus line is highlighted. Of course, I put the SetFocus lines in there in the first place because the previous attempt (without them) told me that I couldn't set the value of a control unless I set focus. ???

So where am I going wrong? Anybody have any ideas for a better approach?

Thanks,
Paul
Sep 14 '07 #1
5 1796
Scott Price
1,384 Expert 1GB
I continually get frustrated with the setfocus method!

One work-around is to place an invisible label with some garbage caption wording in it to act as place holder. Make this label the same size/shape/color/border/etc as the text box. On your open event, if the text value is null, make the text box invisible, the label visible and set it's caption to "0".

Clunky, but effective.

Regards,
Scott
Sep 14 '07 #2
nico5038
3,080 Expert 2GB
Hmm, my approach in general will be to force an additional record when there's no data.
Just create an additional table with one occurrence of all needed keys and use an outer join (Left or Right) with the "child rows" to make sure that when nodata is found a record with the key and Nulls will be available.
Using the NZ() function will make sure it shows as a zero in the report.

Getting the idea ?

Nic;o)
Sep 14 '07 #3
prn
254 Expert 100+
Thanks, guys!

It took a while, but I eventually got what I needed. I used a version of Nico's idea.

Thanks for the good help!

Paul
Sep 19 '07 #4
Scott Price
1,384 Expert 1GB
Glad something worked for you!

Regards,
Scott
Sep 19 '07 #5
nico5038
3,080 Expert 2GB
Thanks for the feedback Paul, glad to know I could contribute to your application :-)

Success !

Nic;o)
Sep 20 '07 #6

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

Similar topics

8
by: Abhi | last post by:
I am in process of designing a report generation application. Now here is breif background about my workplace ...... my system admin is a big microsoft hater .... so does not allow any microsoft...
2
by: CSDunn | last post by:
Hello, I have an Access 2003 report that opens in print preview and then maximizes upon clicking a button from a form. The OnClick event of the button fires a macro to open the report. How can...
0
by: manning_news | last post by:
Using A2K. I've got 2 reports that I want to print one after the other. Below is the coding: DoCmd.OpenReport "rptBilling_FutureCharges", acViewPreview DoCmd.OpenReport "rptBilling_Summary",...
1
by: Rui Soares via AccessMonster.com | last post by:
I have a report with the NoData event and i need to use the OutputTO command to create a .snp file, this is possible??? -- Message posted via AccessMonster.com...
4
by: Richard Sherratt | last post by:
Access 97 and SQL Server 2000. Reports in this system are driven from a parameter form. Parameters are used to make a WHERE clause. If no parameters are selected, strWhere is a zero length...
3
by: Rabbit | last post by:
Dear All, I am working on the formatting of a Crystal Report, I'd noticed that setting BottomLineStyle, and other xxxLineStyle can only be shown when user export the report into PDF format,...
1
by: Jimmy | last post by:
Is there a way to check if there are no records in a filtered form and display an error message such as can be done using the NoData event for a report?
15
by: sara | last post by:
I am stuck. I have a report that I use in multiple places, so I call it with varying parameters (using the Where Clause in the code). I preview the report, send it to snap, then close the...
4
by: cobolguy | last post by:
I have a report that I run from a Macro. This macro executes when you click the printer icon button on the form. The macro is simple: 1. open report 2. printout 3. close report . All this works fine...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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.