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_reports_button_Click()
-
-
On Error GoTo NoData
-
-
DoCmd.OpenReport "Sales Return (TODAY)", acViewNormal
-
DoCmd.OpenReport "Sales/Collections (TODAY)", acViewNormal
-
DoCmd.OpenReport "SRV Register (TODAY)", acViewNormal
-
DoCmd.OpenReport "STPC Voucher Register (TODAY)", acViewNormal
-
DoCmd.OpenReport "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
2 2822
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: -
IF IsNull(DLOOKUP("datefieldname","tablename","datefield=Date()")) then
-
-
else
-
-
endif
-
Dlookup() will return Null when nothing is found.
Clear ?
Nic;o)
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_reports_button_Click()
On Error GoTo NoData
DoCmd.OpenReport "Sales Return (TODAY)", acViewNormal
DoCmd.OpenReport "Sales/Collections (TODAY)", acViewNormal
DoCmd.OpenReport "SRV Register (TODAY)", acViewNormal
DoCmd.OpenReport "STPC Voucher Register (TODAY)", acViewNormal
DoCmd.OpenReport "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: - Private Sub Print_daily_reports_button_Click()
-
On Error GoTo NoData
-
-
If IsNull(DLookup("datefieldname", "tablename", "datefield=Date()")) Then
-
'Print Report for no Data
-
Else
-
DoCmd.OpenReport "Sales Return (TODAY)", acViewNormal
-
End If
-
-
If IsNull(DLookup("datefieldname", "tablename", "datefield=Date()")) Then
-
'Print Report for no Data
-
Else
-
DoCmd.OpenReport "Sales/Collections (TODAY)", acViewNormal
-
End If
-
-
DoCmd.OpenReport "SRV Register (TODAY)", acViewNormal
-
DoCmd.OpenReport "STPC Voucher Register (TODAY)", acViewNormal
-
DoCmd.OpenReport "FIMs issued (today)", acViewNormal
-
-
NoData:
-
-
If Err.Number = 2501 Then
-
Resume Next
-
End If
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
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
|
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...
|
by: Joki |
last post by:
Hi,
All
Can i capture print button click event on crystalreportview control?
Thanx
Joki
|
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...
|
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...
|
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...
|
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. ...
|
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...
|
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>...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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: 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,...
| |