473,471 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Report w/ Query as Datasource

I'm trying to set-up a message box when my report is open that will
say there is no data for the report if there are no records in the
query. I've been able to do this for a form, but it will not work
with my report. Here is the code I use on the Open Event of a form:

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no Open SCAR's", vbInformation
DoCmd.Close
Exit Sub
Else
DoCmd.RunMacro "max"
End If

What do I need to do for this to work on a report?

Thank you!

Chris

Jan 31 '07 #1
7 1508
Just cancel the NoData event of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"chris" <ch**********@yahoo.comwrote in message
news:11********************@k78g2000cwa.googlegrou ps.com...
I'm trying to set-up a message box when my report is open that will
say there is no data for the report if there are no records in the
query. I've been able to do this for a form, but it will not work
with my report. Here is the code I use on the Open Event of a form:

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no Open SCAR's", vbInformation
DoCmd.Close
Exit Sub
Else
DoCmd.RunMacro "max"
End If

What do I need to do for this to work on a report?
Jan 31 '07 #2
Thank you! I actually didn't see that Event. I added the message box
code and close command to the event. The trouble I have now is that I
get an error telling me that I can't close the report because I have
code running under the detail section on the On Format Event. How can
I skip or cancel this code if there is no data?
On Jan 31, 11:23 am, "Allen Browne" <AllenBro...@SeeSig.Invalid>
wrote:
Just cancel the NoData event of the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"chris" <chrisvett...@yahoo.comwrote in message

news:11********************@k78g2000cwa.googlegrou ps.com...
I'm trying to set-up a message box when my report is open that will
say there is no data for the report if there are no records in the
query. I've been able to do this for a form, but it will not work
with my report. Here is the code I use on the Open Event of a form:
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no Open SCAR's", vbInformation
DoCmd.Close
Exit Sub
Else
DoCmd.RunMacro "max"
End If
What do I need to do for this to work on a report?- Hide quoted text -

- Show quoted text -

Jan 31 '07 #3
chris wrote:
If Me.RecordsetClone.RecordCount = 0 Then
IMO, much better to use:

if Me.RecordsetClone.eof then
What do I need to do for this to work on a report?
Use the "On No Data Event" on the report properties.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Jan 31 '07 #4
RecordsetClone is not working with the report

On Jan 31, 11:25 am, Tim Marshall
<TIM...@PurplePandaChasers.Moertheriumwrote:
chris wrote:
If Me.RecordsetClone.RecordCount = 0 Then

IMO, much better to use:

if Me.RecordsetClone.eof then
What do I need to do for this to work on a report?

Use the "On No Data Event" on the report properties.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me

Jan 31 '07 #5
chris wrote:
Thank you! I actually didn't see that Event. I added the message box
code and close command to the event.
Do this instead of the close command:

Private Sub Report_NoData(Cancel As Integer)

MsgBox "The criteria you have selected has yielded no results."

Cancel = True

End Sub

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Jan 31 '07 #6
chris wrote:
RecordsetClone is not working with the report
I did not recommend using it. I should have made it clearer my
preferred method was to do with forms, sorry.

See my response after your post following Allen's response.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Jan 31 '07 #7
Your previous message worked great. Thank you!
On Jan 31, 1:12 pm, Tim Marshall
<TIM...@PurplePandaChasers.Moertheriumwrote:
chris wrote:
RecordsetClone is not working with the report

I did not recommend using it. I should have made it clearer my
preferred method was to do with forms, sorry.

See my response after your post following Allen's response.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me

Feb 2 '07 #8

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

Similar topics

4
by: Grant Stanley | last post by:
I'm developing an application in VS.Net 2003 using C#, which uses Crystal Reports. When creating each report, crystal asks where the database to use is, so I specify our SQL server using the ADO...
7
by: Phin | last post by:
I need your HELP! I've seen all the posts on using Crystal Reports within vs.net (vb.net) and changing a SQL query at runtime. When I tried to pass in a dataset into the crystal report at...
3
by: Edward | last post by:
ACCESS 2k I need to design a report based on a rota system for staff at various shops. The data is effectively stored in a single table, along the lines of: Initials (e.g. BH, FG, RM etc.)...
4
by: Greg Teets | last post by:
I have a table that provides all the details necessary for the line items of the report. I would like to use some other information in the header of the report. This information, like getting...
0
by: Chris | last post by:
I have the following situation in a VB.Net App I am working on: 1.)A report created in VS.Net 2003 using the CR.Net component of VS 2003. 2.)The datasource for the report is a Stored Proc in a...
5
by: sara | last post by:
I have reports that run from a form where the user can choose a date range, or they run automatically for a week in the "Weekly Reports" option. I created 2 queries and 2 reports - one query...
6
by: smcdonald | last post by:
I have a report that opens up using a pretty complex query. I then pop up a form with combo boxes so the user can apply a filter to the existing report and then refresh the report. I need to export...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
3
by: sconard | last post by:
I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a...
1
by: Jassim Rahma | last post by:
anyone has a code sample to connect the Microsoft Report Viewer Control using Microsoft SQL Server stored procedure?
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
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
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.