Solved

Executing the Report_Load() on a SubReport

Posted on 2007-11-28
9
1,154 Views
Last Modified: 2010-04-21
Hello Everyone,

I have a Report that has four sub reports.  Each of the sub reports has a bunch of code that runs as part of the Report_Load() event in each of the sub reports.  When I start my main report, none of the Report_Load event code exeutes.  The code only executes only after I click on the sub report.  I tested each of the sub reports individually and they each work fine.  Its only when they are part of the main report that they do not execute.  Is there a trick to running the sub report's Load event when the main report is started?  Thank you in advance for your help.

0
Comment
Question by:Kozela
  • 5
  • 3
9 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 20371605
Kozela,

Kozela

AFAIK, Reports do not have a "Load" Event. (Forms yes, but not reports)

Also,

As strange as it seems, the subReports actually open before the main Reports.

Try moving your code to the subReports, or vice versa

Hope this helps

JeffCoachman
0
 
LVL 75
ID: 20371861
"As strange as it seems, the subReports actually open before the main Reports."

Actually, there is no guarantee as the the exact order of events regarding Forms/Reports and SubForms/SubReports.

Kozela,
As Jeff mentioned, there is no Load event for a Report.

Re:"executes only after I click on the sub report."
Nor is there any Click event for a report or subreport.  When  you click on a report ... with or without Sub reports ... the only thing that happens is the Zoom effect.

It REALLY sounds like you are talking about Forms and SubForms ???

0
 

Author Comment

by:Kozela
ID: 20373314
Thans guys.  I am a little confused.  The reports that I created have a method called Report_Load() and it seems to start at the very begining.  In fact, I added a MsgBox at the begining of the code to see if it was firing off and it would execute only after I clicked on the subreport.  However, when I run the report by itself, the Msgbox pops up as soon as the report is loaded.  So I guess the question is how can I get the code in the sub reports to fire off when the main Reports loads. Thanks for your help.  
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20373667
Kozela,

Your Tag says "Access 2000"

I have never seen an Report_Load EVENT?

If this a custom Function or Procedure?

Can you post that code here?

JeffC
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20373800
DatabaseMX,
<Actually, there is no guarantee as the the exact order of events regarding Forms/Reports and SubForms/SubReports.>

Correct, I had only tested this on Forms.
I used a messagebox on a few of my Forms/SubForms and the Subform opened first.
However, on the Reports, the MainReport opened first.
;)

Thanks for the clarification.

JeffCoachman
0
 

Author Comment

by:Kozela
ID: 20374132
Jeff,

You are correct.  Access 2000 does not have a Load() event.  I created the report in 2007 but I am using a 2000 database.  My apologies.  Looks like Iike I need to do this in 2000.  I am still stuck with my problem though.  Here is how my sub report is set up.  I use a parameter query as my source for the report.  The user selects a value from a pulldown and that is passed to the query.  Based on the data retrieved, I use that as the criteria i.e.  "...where field1= [retrived field]" for a another set of queries that I execute using VBA and DAO.   The idea is to perform a calculation based on the criteria selected by the user.  I execute three of the following queries:

Private Sub Report_Open()
Dim Total_A_Issued As Integer
Dim Returned_A As Integer
Dim Posted_A As Integer

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strQry As String

Set db = CurrentDb

strQry = "SELECT Sum(Amount) AS Total FROM Movement GROUP BY Batch, Location, Activity, MaterialMoved, FromBatch, To, ToBatch HAVING Batch='" & A-BatchNumber & "' AND Activity='Prod Issue API Mat' AND ToBatch='" & SubBatchNumber & "'"

Set rst = db.OpenRecordset(strQry)

If (rst.RecordCount > 0) Then
    Total_A_Issued = rst!Total

    A_Issued.Value = Total_A_Issued
   
Else
   
    A_Issued.Value = "0"
           
End If

rst.Close
db.Close

.....

End Sub


Thank you for your help again.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20380239
Kozela,

It is difficult to visualize what you have and what you need.
    "A picture is worth a thousand words"
I think it would be easier if you just downloaded a sample of your Database/Report/Form/Code...ect.
Remove any sensitive data, but leave enough data so that we can see the issue.
Along with the post, please explain, in detail, what you are trying to achieve.
Compact/Repair the DB, Zip it then post to:
http://www.ee-stuff.com
...and post the link to that file here.

JeffCoachman
0
 

Author Closing Comment

by:Kozela
ID: 31411591
Jeff C, Thank you for your help and sticking with me.  I went ahead and rearranged the code as you suggested and it worked.  I took out all the VBA code and created the data set I needed for the report using parameter queries.  I then passed in the query as the report data source.  Thank you again.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 20397616
;)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question