UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

> 0 Records return popup msg box    
 
   
Al3x
post Mar 10 2005, 05:21 PM
Post #1

UtterAccess Addict
Posts: 186



is there a way to popup a box when there are no records returned from a query when you wish to create a report?

such as "there are no records in this report" so you dont see the preview
Go to the top of the page
 
+
 
Start new topic
Replies (1 - 15)
R. Hicks
post Mar 10 2005, 05:25 PM
Post #2

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Use the On No Data event of the report to do this ...

RDH
Go to the top of the page
 
+
Al3x
post Mar 10 2005, 05:30 PM
Post #3

UtterAccess Addict
Posts: 186



cheers rick for pointing it out, i never knew there were this feature (IMG:http://www.utteraccess.com/forum/style_emoticons/default/frown.gif)
Go to the top of the page
 
+
R. Hicks
post Mar 10 2005, 05:35 PM
Post #4

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



You are Welcome ... (IMG:http://www.utteraccess.com/forum/style_emoticons/default/wink.gif)

RDH
Go to the top of the page
 
+
Al3x
post Apr 3 2005, 02:37 PM
Post #5

UtterAccess Addict
Posts: 186



Sorry to bother you again but how do i code it to display a msg box and NOT display the report? i got it displaying the msg box but the report appears!
Go to the top of the page
 
+
R. Hicks
post Apr 3 2005, 02:40 PM
Post #6

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Add a line in the On No Data event ...
CODE
Cancel = True

RDH
Go to the top of the page
 
+
Al3x
post Apr 3 2005, 02:46 PM
Post #7

UtterAccess Addict
Posts: 186



that worked but i get an access error sayign the access report open was cancelled, is there any way of displaying a nicer error message after my msg box?
Go to the top of the page
 
+
R. Hicks
post Apr 3 2005, 02:47 PM
Post #8

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Post the code that you are using to open the report ...

RDH
Go to the top of the page
 
+
Al3x
post Apr 3 2005, 02:50 PM
Post #9

UtterAccess Addict
Posts: 186



just the basic ms access wizard:

Private Sub cmdCompReport_Click()
On Error GoTo Err_cmdCompReport_Click

Dim stDocName As String

stDocName = "rptCompReport"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdCompReport_:
Exit Sub

Err_cmdCompReport_Click:
MsgBox Err.Description
Resume Exit_cmdCompReport_

End Sub

Then in my report i have:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data In Report."
Cancel = True
End Sub

Also i have an issue because i have the form on popup the preview report appears behind?
Go to the top of the page
 
+
R. Hicks
post Apr 3 2005, 02:55 PM
Post #10

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Try altering to this:
CODE
Private Sub cmdCompReport_Click()
On Error GoTo Err_cmdCompReport_Click

Dim stDocName As String

stDocName = "rptCompReport"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdCompReport_Click:
  Exit Sub

Err_cmdCompReport_Click:
  If err.Number <> 2501 Then
    MsgBox Err.Description
  End if

  Resume Exit_cmdCompReport_Click

End Sub

RDH
Go to the top of the page
 
+
Al3x
post Apr 3 2005, 03:21 PM
Post #11

UtterAccess Addict
Posts: 186



that did the trick but the report is still at the back of the popup form box? is there anyway of bringing it forward?
Go to the top of the page
 
+
R. Hicks
post Apr 3 2005, 03:27 PM
Post #12

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Either close the form ... or set the form to be hidden when the report opens ...

RDH
Go to the top of the page
 
+
Al3x
post Apr 10 2005, 12:04 PM
Post #13

UtterAccess Addict
Posts: 186



the fix works fine ricky but what exactly does it do? i dont understand the code
Go to the top of the page
 
+
R. Hicks
post Apr 10 2005, 12:13 PM
Post #14

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



I hope I understand what you are asking ....

If the form is set as popup and/or modal ...
Then the get the another object to appear in front of it .. you ether have to close the form or set it's visible property to be hidden ...

If this is not what you are talking about .. explain what code ??

RDH
Go to the top of the page
 
+
Al3x
post Apr 10 2005, 12:15 PM
Post #15

UtterAccess Addict
Posts: 186



sorry i said the wrong thing i meant this code:

CODE
    If err.Number <> 2501 Then    
MsgBox Err.Description  
End if
Go to the top of the page
 
+
R. Hicks
post Apr 10 2005, 12:28 PM
Post #16

UA Forum Administrator
Posts: 38,073
From: Birmingham, Alabama USA



Oh ...

If the user or Access Cancel an operation ... Access will generate the error number 2501.

So the code basically says:
If the error number "is not" 2501 .. display a messagebox to the user to expolaining what may have happened.
Then exit the routine ..

But if the error "is" 2501 .. just exit the routine without any message to the user ...

I hoped I have explained it well enough for you ...

RDH
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th May 2013 - 12:55 AM