473,394 Members | 1,800 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.

Using NoData Event in Access 2003 Report

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 I use the NoData event of the report to present a message box
( with vbOkayOnly) so that when the button is clicked, if the report
returns no data a message box appears, and the report never opens?

I've tried the following in code with the NoData event in a report;

Private Sub Report_NoData(Cancel As Integer)
DoCmd.CancelEvent
MsgBox "There is no data for the selected test.", vbOKOnly, "No Data"
End Sub

When the report has no data, the message box comes up, and the report
does not open, but the form maximizes. I thought that
DoCmd.CancelEvent would cancel the action of opening the report, but
that does not seem to work quite right.

The other thing I have thought about was to just set up a text box in
the report to return a count of student ID's, and if that number were
zero, close the report and show a message box.

Any ideas?

Thank you for your help!

CSDunn
Nov 13 '05 #1
2 5423
On 16 Nov 2004 16:02:05 -0800, CSDunn wrote:
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 I use the NoData event of the report to present a message box
( with vbOkayOnly) so that when the button is clicked, if the report
returns no data a message box appears, and the report never opens?

I've tried the following in code with the NoData event in a report;

Private Sub Report_NoData(Cancel As Integer)
DoCmd.CancelEvent
MsgBox "There is no data for the selected test.", vbOKOnly, "No Data"
End Sub

When the report has no data, the message box comes up, and the report
does not open, but the form maximizes. I thought that
DoCmd.CancelEvent would cancel the action of opening the report, but
that does not seem to work quite right.

The other thing I have thought about was to just set up a text box in
the report to return a count of student ID's, and if that number were
zero, close the report and show a message box.

Any ideas?

Thank you for your help!

CSDunn


Don't maximize the report from the button on the form.
Simply code the Report's Open event:
DoCmd.Maximize

To return to the un-maximized form when you close the report, code the
Report's Close Event:
DoCmd.Restore

Try the code in theReport's OnNoData event this way.

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for the selected test.", vbOKOnly, "No Data"
Cancel = True
End Sub

Note: You will probably get a "You canceled this action..." error
message.
Trap Error 2501 in the command button event that opens the report.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2
> 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.
So how exactly does the report get maximized?
When the report has no data, the message box comes up, and the report
does not open, but the form maximizes. I thought that
Okay, nevermind, I think I understand what's going on. It's just an
MDI thing. When there's data on the report it'll come up full screen,
but then when you close the report, the form is maximized, too, right?
That's how MDI works.
DoCmd.CancelEvent would cancel the action of opening the report, but
that does not seem to work quite right.
How can it know there's no data without opening and processing the
report...?
The other thing I have thought about was to just set up a text box in
the report to return a count of student ID's, and if that number were
zero, close the report and show a message box.


Better yet, if that number is zero, set the button's ( that opens the
report ) enabled property to false.
Nov 13 '05 #3

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

Similar topics

6
by: Jarrod | last post by:
I have multiple reports in one database, on one form. I need to know what reports were run when, and by Network User ID. How do I do that?
2
by: BikeToWork | last post by:
I found code online which uses Windows API's to save Access reports to pdf format files. I'm using the full version of Adobe Acrobat Professional 7.0. The problem is that regardless of what I put...
1
by: seawolf | last post by:
Is there a way to create a numbering for the Details in an Access 2003 Report. For instance, if a report has 12 records that make up the Details in a report, can these be numbered, i.e., 1, 2, 3, 4,...
0
by: cbj0517 | last post by:
Hello: I am trying to create a Pivot table in an Access 2003 report. I have SQL that retunrs 6 columns of data, (month_year, units, products_per_unit, gross_sales, price_pe_product, and...
1
by: klinke1006 | last post by:
Hi, I have written several Access 2003 reports. These reports run properly for some of the users of the Access Application. For others a report that should display on one page displays on many...
5
by: lionelm2007 | last post by:
When I view a report in another machine, it looks slightly different. First of all, the logo in the report heading does not show up when you print, also in print preview, you can see the last letter...
1
by: J360 | last post by:
In Access 2003, I'm creating a dynamic report and am trying to place text boxes into group headers. One report will have 6 group levels. I can place controls in the first two group headers easily...
2
pbala
by: pbala | last post by:
hello, I created the user level security for one MS Access 2003 database.It created one Shortcut file in Desktop. Now I want to share the database with my company workers. How i will share the...
14
by: Karen D | last post by:
Hello Experts! I am running a report on a query in Access 2003 and I need to get the median(s) for several different fields in the footer of the report. I am currently using this solution from...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.