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

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 = "rptEstFreight0ActualNOT0"
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 = "rptImpactofFreightChanges-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(Cancel As Integer)
Dim WeekEndDate As Date
Dim WeekStartDate As Date

WeekStartDate = [Forms]![frmPrintPOReports]![getSaleDate]
WeekEndDate = [Forms]![frmPrintPOReports]![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 4901
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.OpenReport RptName, acViewPreview

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

DoCmd.OpenReport RptName, acViewDesign
Report(RptName).InputParameters = "@parm1='x',@parm2='y'"
DoCmd.Close acReport, RptName, acSaveYes
DoCmd.OpenReport 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 = "rptEstFreight0ActualNOT0"
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 = "rptImpactofFreightChanges-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(Cancel As Integer)
Dim WeekEndDate As Date
Dim WeekStartDate As Date

WeekStartDate = [Forms]![frmPrintPOReports]![getSaleDate]
WeekEndDate = [Forms]![frmPrintPOReports]![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 = "rptEstFreight0ActualNOT0"
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 = "rptImpactofFreightChanges-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(Cancel As Integer)
Dim WeekEndDate As Date
Dim WeekStartDate As Date

WeekStartDate = [Forms]![frmPrintPOReports]![getSaleDate]
WeekEndDate = [Forms]![frmPrintPOReports]![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
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...
9
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....
0
by: khairihusseini | last post by:
I have following code: Private Sub SetDataBaseLocation(ByVal Report As ReportDocument) For Each oConnectionInfo As .IConnectionInfo In Report.DataSourceConnections...
1
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...
17
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...
1
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...
6
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...
8
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...
14
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
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
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...
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.