Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / October 2005

Tip: Looking for answers? Try searching our database.

Repost: Cancel Print if Subreport not Visible

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CJ - 27 Oct 2005 22:03 GMT
I'm sure this is simple but I'm missing it........

Hi

I have a subreport that is set to be invisible if it does not contain any
data. This had to be done because of another report that the sub is used on.

Anyway, how do I tell a main report to show a message box and cancel
printing if this particular subreport is not visible.

The code I have is as follows, but is not working:

Private Sub Report_Activate()
   If (Me!rsubPumpsInStock.Visible = False) Then
       MsgBox "No pumps in stock, cancelling report printing",
vbExclamation, ""
       DoCmd.CancelEvent
   End If
End Sub

 
I'm not sure which report event to use either.....

Thanks
CJ
Ofer - 27 Oct 2005 22:49 GMT
Instead of checking if the sub report is visible, check if it has any data

Private Sub Report_Activate()
   If Me!rsubPumpsInStock.Report.HasData = False Then
       MsgBox "No pumps in stock, cancelling report printing",
vbExclamation, ""
       DoCmd.Close acReport, "ReportName"    
   End If
End Sub
This code should be on the On Activate event of the Main Report
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> I'm sure this is simple but I'm missing it........
>
[quoted text clipped - 21 lines]
> Thanks
> CJ
CJ - 28 Oct 2005 02:52 GMT
Brilliant, thanks very much.

I had to make one adjustment.....the End If statement had to come out.

Thanks again!
> Instead of checking if the sub report is visible, check if it has any data
>
[quoted text clipped - 32 lines]
>> Thanks
>> CJ
CJ - 28 Oct 2005 03:05 GMT
Oooops, actually, not quite. If the report does have data, then it just
cancels the print preview.

I have tried adding an ElseIf to make it work but no luck.

Any suggestions?
> Brilliant, thanks very much.
>
[quoted text clipped - 39 lines]
>>> Thanks
>>> CJ
Ofer - 28 Oct 2005 07:48 GMT
Can you post the code?
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> Oooops, actually, not quite. If the report does have data, then it just
> cancels the print preview.
[quoted text clipped - 45 lines]
> >>> Thanks
> >>> CJ
Ofer - 28 Oct 2005 12:10 GMT
The If has to be there, so I don't understand how did you remove the End If

If there is no if, the report will be always close
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> Oooops, actually, not quite. If the report does have data, then it just
> cancels the print preview.
[quoted text clipped - 45 lines]
> >>> Thanks
> >>> CJ
CJ - 30 Oct 2005 17:49 GMT
Hi, sorry for the delay.

I solved it with the following code:

           If Me!rsubPumpsInStock.Report.HasData = False Then
               DoCmd.Close
               MsgBox "No Pumps In Stock. Report Preview Cancelled",
vbInformation
           Else
               DoCmd.Maximize
           End If

I just changed the order of the events, making sure that the report closed
first. I'm not sure what happened with the End If thing, I don't remember
anymore.

Thanks for all of your help.

> The If has to be there, so I don't understand how did you remove the End
> If
[quoted text clipped - 51 lines]
>> >>> Thanks
>> >>> CJ
Ofer - 30 Oct 2005 23:41 GMT
I'm happy you got it sorted out.
Good luck with your project
Signature

If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck

> Hi, sorry for the delay.
>
[quoted text clipped - 69 lines]
> >> >>> Thanks
> >> >>> CJ
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.