Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-04-2019, 03:16 AM   #1
Juett
Newly Registered User
 
Join Date: Jul 2019
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Juett is on a distinguished road
Sub report VBA not firing when loaded through main report

Hi Guys,

I have a little issue with some VBA code in a sub report.

The following code works in the sub report when opened directly:

Code:
Private Sub Report_Load()
If IsNull(cmb1.Value) Then
    Me.img1.Visible = False
Else
    Me.img1.Visible = True
End If
End Sub
It displays or hides an image based on the value of a combo box.

But...when I insert this report as a sub report in another (main form) and open it, the code does not fire.

What do you think I might be missing?

Thanks very much.

Juett is offline   Reply With Quote
Old 10-04-2019, 03:24 AM   #2
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,401
Thanks: 68
Thanked 2,703 Times in 2,588 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Sub report VBA not firing when loaded through main report

reports event don't fire when inserted as subreport.
set it on the main reports load event:

private sub report_load()
me.subreportname!img1.Visible = (IsNull(me.subreportname!cmb1)=False)
end sub
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 10-04-2019, 04:50 AM   #3
Juett
Newly Registered User
 
Join Date: Jul 2019
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
Juett is on a distinguished road
Re: Sub report VBA not firing when loaded through main report

That worked perfectly, thanks very much!

Juett is offline   Reply With Quote
Old 10-04-2019, 04:53 AM   #4
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,401
Thanks: 68
Thanked 2,703 Times in 2,588 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Sub report VBA not firing when loaded through main report

you are welcome!

__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop Report On Close event from firing when No Data JeffBarker Modules & VBA 10 12-19-2016 07:18 AM
[SOLVED] Open sub report from main report by selecting report name scopes456 Reports 3 12-15-2015 11:01 AM
2007 Report events not firing with Outputto method AlexP Reports 0 08-13-2007 11:23 AM
Setting all loaded forms to visible=no when a report is opened MarionD Modules & VBA 2 12-19-2006 06:49 AM
Report Printing Before its fully loaded racemadnss Reports 1 07-26-2004 10:42 AM




All times are GMT -8. The time now is 05:59 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World