UtterAccess Discussion Forums
  UtterAccess Home  | Forums Index  | Search  | Links DB  | FAQs   
Microsoft® Access help forums plus Excel, Word, Outlook®, Visual Basic®, SQL Server®, Office online and... many more!

Access UtterAccess!
New? Welcome!
Join UA here!

Members Login


Password


Remember me!


Search The Database

More Links

  UtterAccess Links
  Link to UtterAccess
  Call UtterAccess Home
  Add UA to Favorites

Quick Jump



UA Recommended

Access Team Blog

UA Recommended

UA's own ScottGem
      and datAdrenaline!

Servers tuned by
Peak Services
Report With No Data.......

  Re: Report With No Data.......  Version: 2003 (11.0) [Re: Aquadevel]

Posted on 04/11/08 11:34 PM
Posted by Aquadevel - Utter Access VIP
Posts: 5957 - Loc: Earth...

Forum: Access Reports
• Edit
• Reply
• Quote
• Quick Reply
• Print this post
• Bookmark Post
• Notify Moderator

• Top of page
Chris,

As to the:

"It’s a faulty premise to check the Reports Record Source for record count since the Reports Filter may reduce that count to zero. (Besides, the Report has a HasData property so why not use it?)
......"
In my case, right now there are no filters in the report itself.

But, I am going to check out the original code in the morning.

--------------------
Aqua

< Sharing is caring >

  Re: Report With No Data.......  Version: 2003 (11.0) [Re: Rainlover]

Posted on 04/11/08 11:48 PM Attachment (7 downloads)
Posted by ChrisO - Utter Access VIP
Posts: 3008 - Loc: Brisbane, Australia

Forum: Access Reports
• Edit
• Reply
• Quote
• Quick Reply
• Print this post
• Bookmark Post
• Notify Moderator

• Top of page
G’day Des.

Hmmmmmmmmmmmmmmmmm.

Please try the attached.

Regards,
Chris.


--------------------
A nod's as good as a wink to a blind horse.

  Re: Report With No Data.......  Version: 2003 (11.0) [Re: Rainlover]

Posted on 04/12/08 01:05 AM
Posted by datAdrenaline - Utter Access VIP
Posts: 8489 - Loc: Evansville, Indiana, USA

Forum: Access Reports
• Edit
• Reply
• Quote
• Quick Reply
• Print this post
• Bookmark Post
• Notify Moderator

• Top of page
Hey Aqua ...

The code you got from scott is inefficient compared to using the NoData event ( Click Here for more details) ...

Also ... with respect to the code you posted that looks like this:

Code:
Private Sub cmdPrinter_Click() 
On Error Resume Next
Dim stDocName As String
stDocName = "Client Service Report"
DoCmd.OpenReport stDocName, acViewPreview
If Err = 2501 Then Err.Clear
End sub

------

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData
MsgBox "There are currently no records for that date range"
Cancel = True
Exit_Report_NoData:
Exit Sub
Err_Report_NoData:
MsgBox Err.Description
Resume Exit_Report_NoData
End Sub



Why so much code?.... I personally don't check for the error number, some argue, and rightfully so, that not checking for a specific error is circumventing the issue. But to me, with these simple code blocks, there is really no need for specific error checking... and definately no need for error checking in the NoData event since you are just displaying a message box ...

So ... I would suggest this:
Code:
Private Sub cmdPrinter_Click() 
On Error Resume Next
DoCmd.OpenReport "Client Service Report", acViewPreview
End sub

------

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There are currently no records for that date range"
Cancel = True
End Sub



....

This may be what ChrisO has ... but that is doubtful as he has, IMO, some of the best error trapping code and practices I seen! ...

--------------------
Brent Spaulding | datAdrenaline | Access MVP
Pay it Forward ... It will enrich the lives of many!

  Re: Report With No Data.......  Version: 2003 (11.0) [Re: TheGOG]

Posted on 04/12/08 01:09 AM
Posted by datAdrenaline - Utter Access VIP
Posts: 8489 - Loc: Evansville, Indiana, USA

Forum: Access Reports
• Edit
• Reply
• Quote
• Quick Reply
• Print this post
• Bookmark Post
• Notify Moderator

• Top of page
Hello TheGOG ...

>> Cancel is set up as integer, but you use a boolean. Is that valid? <<

The short answer is yes ... a boolean is essentially a formatted integer, much like a date/time is a formatted double. As boolean of True is the integer equivalent of -1, and False is an integer of 0.

--------------------
Brent Spaulding | datAdrenaline | Access MVP
Pay it Forward ... It will enrich the lives of many!


  Re: Report With No Data.......  Version: 2003 (11.0) [Re: TheGOG]

Posted on 04/12/08 11:17 AM
Posted by Aquadevel - Utter Access VIP
Posts: 5957 - Loc: Earth...

Forum: Access Reports
• Edit
• Reply
• Quote
• Quick Reply
• Print this post
• Bookmark Post
• Notify Moderator

• Top of page
Its a new day.......

Brent,

as to the:

"Why so much code?.... .."

I need to trap the dang error 2501

As to the:

"Any way ... checking the count of the query before opening a report isn't so bad, but you are opening a recordset TWICE if the count is greater than 0 ... once to perform the DCount() and once to create the report....."

Now thats NOT good, IMHO.

As to the:

"This may be what ChrisO has ... but that is doubtful as he has, IMO, some of the best error trapping code and practices I seen! ..."

I agree 1000%!

So, as I had stated, yesterday was a 'terrible' day, too many things in the fire, etc.

What I did find this morning was, as Van had suggested, the "Break On UnHandled Error's".
When I looked it it last nite, I could swear it was on Unhandled, but in rechecking everything this morning,
it was in fact set to 'Break On All Errors'.

So, to get everyone happy , I am using Chris's initial code in the button, & reports OnNoData,
and everything is hunky-dory!

Thanks for ALL the input/info guys!!!







--------------------
Aqua

< Sharing is caring >

  Re: Report With No Data.......  Version: 2003 (11.0) [Re: Aquadevel]

Posted on 04/12/08 02:44 PM
Posted by datAdrenaline - Utter Access VIP
Posts: 8489 - Loc: Evansville, Indiana, USA

Forum: Access Reports
• Edit
• Reply
• Quote
• Quick Reply
• Print this post
• Bookmark Post
• Notify Moderator

• Top of page
Hey Aqua!! ...

Yep ... its a brand new day!! .... glad to hear you got is sorted!!! ...

In response to ...

>> I need to trap the dang error 2501 <<

My code does that too .... I just use the On Error Resume Next to do it. Any way ... as we have said, its a brand new day! ... its amazing what a break from the situation will do for you!! ... Hope your day goes well!!

--------------------
Brent Spaulding | datAdrenaline | Access MVP
Pay it Forward ... It will enrich the lives of many!

Page Jump
Pages: 1 | 2 | 3 | (show all)

Navigate
Post List
Previous thread Previous
Next thread Next

Thread Options & Info
• Threaded
• Print Thread

• 471 Thread views

Page Jump
Pages: 1 | 2 | 3 | (show all)