My Assistant
|
|
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 |
|
|
|
![]() |
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 |
|
|
|
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)
|
|
|
|
Mar 10 2005, 05:35 PM
Post
#4
|
|
|
UA Forum Administrator Posts: 38,073 From: Birmingham, Alabama USA |
|
|
|
|
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!
|
|
|
|
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 |
|
|
|
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?
|
|
|
|
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 |
|
|
|
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? |
|
|
|
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 |
|
|
|
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?
|
|
|
|
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 |
|
|
|
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
|
|
|
|
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 |
|
|
|
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 |
|
|
|
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 Top · Lo-Fi Version | Time is now: 20th May 2013 - 12:55 AM |