473,802 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print another report on a OnNoData event

1 New Member
Hi

I currently have the following code attached to a command button on a switchboard form. This is basic Access 2000.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_daily_reports_button_Click()
  2.  
  3. On Error GoTo NoData
  4.  
  5.     DoCmd.OpenReport "Sales Return (TODAY)", acViewNormal
  6.     DoCmd.OpenReport "Sales/Collections (TODAY)", acViewNormal
  7.     DoCmd.OpenReport "SRV Register (TODAY)", acViewNormal
  8.     DoCmd.OpenReport "STPC Voucher Register (TODAY)", acViewNormal
  9.     DoCmd.OpenReport "FIMs issued (today)", acViewNormal
  10.  
  11. NoData:
  12.  
  13. If Err.Number = 2501 Then
  14. Resume Next
  15. End If
  16.  
  17. End Sub
For the first 2 reports, I have another report that will just print a separate report when there are no items to report. I am trying to work out the code needed.

I have tried setting on the report's NoData event to print the other report but the macro stops. Is there a way to refer to the NoData event in the code builder as above?

Prior to the above code builder I have also tried a macro to print all the same reports with a separate macro in the sales return report on the nodata event but that comes with the error "The function Open Report is not available now".

Any ideas will be greatly appreciated.

Thanks
Mar 21 '07 #1
2 2852
nico5038
3,080 Recognized Expert Specialist
You should check the report's query to return records before triggering the report.

One way is to use a recordset for this, but as I guess you only need to check a specific date, the DLOOKUP() could be an alternative like:
Expand|Select|Wrap|Line Numbers
  1. IF IsNull(DLOOKUP("datefieldname","tablename","datefield=Date()")) then
  2.  
  3. else
  4.  
  5. endif
  6.  
Dlookup() will return Null when nothing is found.

Clear ?

Nic;o)
Mar 25 '07 #2
ADezii
8,834 Recognized Expert Expert
Hi

I currently have the following code attached to a command button on a switchboard form. This is basic Access 2000.

Private Sub Print_daily_rep orts_button_Cli ck()

On Error GoTo NoData

DoCmd.OpenRepor t "Sales Return (TODAY)", acViewNormal
DoCmd.OpenRepor t "Sales/Collections (TODAY)", acViewNormal
DoCmd.OpenRepor t "SRV Register (TODAY)", acViewNormal
DoCmd.OpenRepor t "STPC Voucher Register (TODAY)", acViewNormal
DoCmd.OpenRepor t "FIMs issued (today)", acViewNormal

NoData:

If Err.Number = 2501 Then
Resume Next
End If

End Sub

For the first 2 reports, I have another report that will just print a separate report when there are no items to report. I am trying to work out the code needed.

I have tried setting on the report's NoData event to print the other report but the macro stops. Is there a way to refer to the NoData event in the code builder as above?

Prior to the above code builder I have also tried a macro to print all the same reports with a separate macro in the sales return report on the nodata event but that comes with the error "The function Open Report is not available now".

Any ideas will be greatly appreciated.

Thanks
Nico has the right idea, just substitute you own Parameters:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_daily_reports_button_Click()
  2. On Error GoTo NoData
  3.  
  4. If IsNull(DLookup("datefieldname", "tablename", "datefield=Date()")) Then
  5.   'Print Report for no Data
  6. Else
  7.   DoCmd.OpenReport "Sales Return (TODAY)", acViewNormal
  8. End If
  9.  
  10. If IsNull(DLookup("datefieldname", "tablename", "datefield=Date()")) Then
  11.   'Print Report for no Data
  12. Else
  13.   DoCmd.OpenReport "Sales/Collections (TODAY)", acViewNormal
  14. End If
  15.  
  16. DoCmd.OpenReport "SRV Register (TODAY)", acViewNormal
  17. DoCmd.OpenReport "STPC Voucher Register (TODAY)", acViewNormal
  18. DoCmd.OpenReport "FIMs issued (today)", acViewNormal
  19.  
  20. NoData:
  21.  
  22. If Err.Number = 2501 Then
  23.   Resume Next
  24. End If
  25. End Sub
Mar 25 '07 #3

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

Similar topics

0
1359
by: Michael Dekson | last post by:
Access 97. I make a report and I want first to see report and then print report without type CONTROL + P. Can I make some button or can I see print button in toolbar meny. Thanks
2
3321
by: ChadDiesel | last post by:
Hello, I have a form and subform with their tables linked by a field called Load_ID. I have a button on my subform that prints just the items listed on that particular subform (looking at Load_ID). I'm using the following code: DoCmd.OpenReport "Load Sheet", acPreview, , "= " & "'" & Me.Parent.Form! & "'" This works fine, but now I want to automate the process, so I set the
0
1303
by: Joki | last post by:
Hi, All Can i capture print button click event on crystalreportview control? Thanx Joki
5
1784
by: Tony Dong | last post by:
Hi there, I am newer for dot net I want to make a report and then print it, the report may include images and text, how can I do that, any one can give me a suggestion? I know how to working with printers, but it looks just support text or image separately. Can I use cystal report to make a report and then use dot net program to
1
1984
by: thh108688 | last post by:
Hi All, Is anyone know how to do a print report based on my current record. What i would like to get is once i have entered all the value in the form, when i hit the print button, all the value will be printed in a nice word document. It is good if someone can give me an example when explaining as i am quite new with Access. Sick of coding! Appreciate for that! Cheers Ray
2
1860
by: felicia | last post by:
Can anyone help me on How to use Data Report in VB and how to print report? I hope i can generate the Data Report without Data Environment because I am not fammiliar with it. Simple adodb or adodc connection is fine for me.
10
9126
by: Snoopy33 | last post by:
I have a DB that I developed on access XP (2002) and deployed over a year ago. No one has had problems printing any of the reports within the DB until we started loading 2007 on new computers. The access 2007 users cannot print one of the reports. This is maddening since I cannot duplicate the issue on any computer that runs 2003 or below. Is there something going on that I'm not seeing? Does anyone have any suggestions at all on...
0
2727
by: Fred Zuckerman | last post by:
Hi All, I have a report with an accumulating value control. I use the Detail_Format event to periodically change the backcolor of the control. The control (Me.Tot) prints green except for the records where it reaches a multiple of 300. In the Open event I set the variable Milestone to an initial value of 300. On the initial records, Me.Tot prints with backcolor of green. When Me.Tot reaches 300 I change the backcolor to red and reset...
1
4119
by: abil | last post by:
i've already build a program that contain all the price, the change given back to the customer but i dun have no idea which function i should use to do program print report... #include <cstdlib> #include <iostream> #include<iomanip> using namespace std; const int TEH_TARIK = 0; const int NESCAFE = 1; const int HORLICK = 2; const int TEH_O = 3;
0
9699
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
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
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
10285
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
10063
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...
0
9115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5494
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...
1
4270
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 we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.