?
Solved

Executing the Report_Load() on a SubReport

Posted on 2007-11-28
9
Medium Priority
?
1,209 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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

770 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