473,569 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(C ancel As Integer)
DoCmd.CancelEve nt
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.CancelEve nt 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 5432
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(C ancel As Integer)
DoCmd.CancelEve nt
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.CancelEve nt 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(C ancel 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.CancelEve nt 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
4450
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
4354
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 in the code as a filename it automatically saves the report based on the report name instead of the string passed to the registry key. The code is...
1
1583
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, etc., for each Detail record.
0
2218
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 avg_days_to_fulfill). I would like the columns of the pivot to be the months of the year, and a row for each of the other columns, with a total column at the...
1
1334
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 pages. Has anyone experienced this and can you help me solve it? Thanks Sue
5
3337
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 is missing from several texts. I have read other postings online and have done why they asked to check. I have checked that the printer settings...
1
2730
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 by using the acGroupLevel1/2Header option. How do I place in the other group headers? acGroupLevel3Header doesn't appear to exist and manually typing...
2
2857
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 Database? Thanks...
14
2619
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 Microsoft (http://support.microsoft.com/kb/210581): I pasted Function Median (tName As String, fldName As String) As Single Dim MedianDB As...
0
7614
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...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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...
1
7676
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...
1
5513
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...
0
5219
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...
0
3653
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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

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.