Solved

Executing the Report_Load() on a SubReport

Posted on 2007-11-28
9
1,168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

726 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