Solved

Executing the Report_Load() on a SubReport

Posted on 2007-11-28
9
1,111 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now