473,800 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No Data Stop Report - How to tell VBA to Run Next Report?

Hi -
I have a button that runs 2 reports. If there is no data on the
report, I use the No Data event, and tell the user, and Cancel the
execution of that report.

However, if the first report has no data, the second report doesn't
run. All execution stops.

Is there a way in VBA to go on to the next report after the No Data?

thanks -
Sara

(Code Below)

Case Is = 8

strDocName = "rptEstFreight0 ActualNOT0"
strStepErrorMsg = "Tell IT there was a problem with Request
Est 0 Actual Not"

strFile = strDocName & ".snp"
strPathAndFile = strPath & strFile
DoCmd.OutputTo acOutputReport, strDocName, "snapshot format",
_
strPathAndFile

strDocName = "rptImpactofFre ightChanges-Range"
strStepErrorMsg = "Tell IT there was a problem with Request
Impact Freight Change by dates"

strFile = strDocName & ".snp"
strPathAndFile = strPath & strFile
DoCmd.OutputTo acOutputReport, strDocName, "snapshot format",
_
strPathAndFile

Report No Data:
Private Sub Report_NoData(C ancel As Integer)
Dim WeekEndDate As Date
Dim WeekStartDate As Date

WeekStartDate = [Forms]![frmPrintPORepor ts]![getSaleDate]
WeekEndDate = [Forms]![frmPrintPORepor ts]![getWkMoDate]

'Tell the user there is no data

MsgBox "There are no POs for the Period Between " & _
WeekStartDate & " And " & WeekEndDate & _
" With Estimated Freight 0 and Actual Freight on file"

Cancel = True

End Sub

Oct 6 '06 #1
3 4933
Hi Sara,

you could simplify your system a little bit by doing the checks before
openeing the report. You did not describe your scenario with much
detail, but the standard scenario is that you have user form with
buttons for selecting various reports. The report datasource is
established at desing time. In the user form you can check to see if
the datasource has data first. If not, give the user a message that
there is no data for the given parameters. If there is data then

DoCmd.OpenRepor t RptName, acViewPreview

Or if you have parameters for the report you can do this:

DoCmd.OpenRepor t RptName, acViewDesign
Report(RptName) .InputParameter s = "@parm1='x',@pa rm2='y'"
DoCmd.Close acReport, RptName, acSaveYes
DoCmd.OpenRepor t RptName, acViewPreview

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Oct 6 '06 #2
sara wrote:
Hi -
I have a button that runs 2 reports. If there is no data on the
report, I use the No Data event, and tell the user, and Cancel the
execution of that report.

However, if the first report has no data, the second report doesn't
run. All execution stops.

Is there a way in VBA to go on to the next report after the No Data?

thanks -
Sara

(Code Below)

Case Is = 8

strDocName = "rptEstFreight0 ActualNOT0"
strStepErrorMsg = "Tell IT there was a problem with Request
Est 0 Actual Not"

strFile = strDocName & ".snp"
strPathAndFile = strPath & strFile
DoCmd.OutputTo acOutputReport, strDocName, "snapshot format",
_
strPathAndFile

strDocName = "rptImpactofFre ightChanges-Range"
strStepErrorMsg = "Tell IT there was a problem with Request
Impact Freight Change by dates"

strFile = strDocName & ".snp"
strPathAndFile = strPath & strFile
DoCmd.OutputTo acOutputReport, strDocName, "snapshot format",
_
strPathAndFile

Report No Data:
Private Sub Report_NoData(C ancel As Integer)
Dim WeekEndDate As Date
Dim WeekStartDate As Date

WeekStartDate = [Forms]![frmPrintPORepor ts]![getSaleDate]
WeekEndDate = [Forms]![frmPrintPORepor ts]![getWkMoDate]

'Tell the user there is no data

MsgBox "There are no POs for the Period Between " & _
WeekStartDate & " And " & WeekEndDate & _
" With Estimated Freight 0 and Actual Freight on file"

Cancel = True

End Sub
If you Cancel, it probably returns back to your error routine with a
2501 error.

If so, see if this works in the error routine
If Err.Number = 2501 then
resume next
else
...process error as usual
Endif

Oct 6 '06 #3
You did it again - that's all I needed! (Of course, I feel like a
genious right now)
And it was really so simple!

thanks so much -
Sara

salad wrote:
sara wrote:
Hi -
I have a button that runs 2 reports. If there is no data on the
report, I use the No Data event, and tell the user, and Cancel the
execution of that report.

However, if the first report has no data, the second report doesn't
run. All execution stops.

Is there a way in VBA to go on to the next report after the No Data?

thanks -
Sara

(Code Below)

Case Is = 8

strDocName = "rptEstFreight0 ActualNOT0"
strStepErrorMsg = "Tell IT there was a problem with Request
Est 0 Actual Not"

strFile = strDocName & ".snp"
strPathAndFile = strPath & strFile
DoCmd.OutputTo acOutputReport, strDocName, "snapshot format",
_
strPathAndFile

strDocName = "rptImpactofFre ightChanges-Range"
strStepErrorMsg = "Tell IT there was a problem with Request
Impact Freight Change by dates"

strFile = strDocName & ".snp"
strPathAndFile = strPath & strFile
DoCmd.OutputTo acOutputReport, strDocName, "snapshot format",
_
strPathAndFile

Report No Data:
Private Sub Report_NoData(C ancel As Integer)
Dim WeekEndDate As Date
Dim WeekStartDate As Date

WeekStartDate = [Forms]![frmPrintPORepor ts]![getSaleDate]
WeekEndDate = [Forms]![frmPrintPORepor ts]![getWkMoDate]

'Tell the user there is no data

MsgBox "There are no POs for the Period Between " & _
WeekStartDate & " And " & WeekEndDate & _
" With Estimated Freight 0 and Actual Freight on file"

Cancel = True

End Sub
If you Cancel, it probably returns back to your error routine with a
2501 error.

If so, see if this works in the error routine
If Err.Number = 2501 then
resume next
else
...process error as usual
Endif
Oct 6 '06 #4

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

Similar topics

5
5421
by: David Gray | last post by:
Greetings all, How can I use ADODB to return all tables in an access DB chosen by the user? I'm able so far to select the DB file and build up my connect string, but I would like to offer a list of tables withing the DB and allow the user to choose. Is this possible using MS ActiveX Data Objects 2.0 Library or do I
9
2066
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1. Assign to a datarow (dr1) the first record of the MASTER table 2. Assign to another datarow (dr2) the second record of the MASTER table 3. If dr1.field1 = dr2.field1, then proceed, otherwise do stop 4. Assign to a third datarow (dr3) the first record...
0
1301
by: khairihusseini | last post by:
I have following code: Private Sub SetDataBaseLocation(ByVal Report As ReportDocument) For Each oConnectionInfo As .IConnectionInfo In Report.DataSourceConnections oConnectionInfo.SetConnection(_Servername, _DatabaseName, _Username, _Password) oConnectionInfo.SetLogon(_Username, _Password) Next
1
1975
by: clusardi2k | last post by:
Hello, the step that I did to get to my current question are: I began to use the keyword DataDirectory and the next line of code. When I ran the application, I would be asked for a Login ID and password. If I clicked the cancell button on that Login window I would not see the report at all. CrystalReport1.Load(Application.StartupPath & "\..\..\CrystalReport1.rpt")
17
3554
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is populated when a user scans a label. The other is ScanDate - a date/time field that should equal the date/time of the scan (e.g. 7/31/2006 5:00:00 AM).
1
17959
by: Rich | last post by:
Hello, I am trying to use the Reportviewer control. I have been following an example from the web, and the instructions from the help files on set up a ..rdlc and binding it to the reportviewer control. The help files state that in the form the contains the reportviewer control there is a tasks smart tags panel in design view. I don't see any such thing. Where do I need to look to see this panel? So I have been trying to follow...
6
6871
by: Phil Stanton | last post by:
I am running a query that calls a function used to format addresses depending on the width of a control on a report that shows that address. The same query is used as the RecordSource of lots of similar reports, but all with different sized Address text boxes. For the function to work, the report need to be open in design view, so that the Text Box Width can be "measured". The function is obviously called for each line of the query (about...
8
3091
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly on my DataGrid but I'm not sure how to get Crystal Reports 10 to use as its datasource the dataset...
14
7865
ollyb303
by: ollyb303 | last post by:
Hi, I am trying to create a dynamic crosstab report which will display number of calls handled (I work for a call centre) per day grouped by supervisor. I have one crosstab query (Query1) which has the following fields: SPID (supervisor ID), total:group by, as row heading Date, total:group by, as column heading Calls handled, total:sum, as value Date, total:where, criteria between and - this is taken from a form,
0
9551
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
10275
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...
0
9085
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...
1
7576
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
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
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...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
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.