• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1274
  • Last Modified:

Executing the Report_Load() on a SubReport

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
Kozela
Asked:
Kozela
  • 5
  • 3
1 Solution
 
Jeffrey CoachmanCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"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
 
KozelaAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Jeffrey CoachmanCommented:
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
 
Jeffrey CoachmanCommented:
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
 
KozelaAuthor Commented:
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
 
Jeffrey CoachmanCommented:
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
 
KozelaAuthor Commented:
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
 
Jeffrey CoachmanCommented:
;)
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now