A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

issue with reading the value in the subreport from report



 
 
Thread Tools Display Modes
  #1  
Old February 4th, 2009, 01:36 AM posted to microsoft.public.access.reports
associates
external usenet poster
 
Posts: 132
Default issue with reading the value in the subreport from report

Hi,

I have been trying to make the following VB code to work but with no luck.
Wonder if anyone might be able to help me out.

Me.TotNumOfStudents = Sum([Reports]![Students Report]![StudentsPerClass])

I have a report called MasterReport which has a subreport, called "Students
Report". What i want to do here is to be able to work out a total of number
of students per classroo. To do this, i need to do a sum of StudentsPerClass
that exists in the subreport, Students Report. When i run the code, it
prompts me for the value of StudentsPerClass in a Windows Dialog box.

The textbox of TotNumOfStudents is actually in the MasterReport, though.

I donot understand why it did not like it. Would it be because the subreport
has not yet been run and therefore the MasterReport can not know the value
for the textbox TotNumOfStudents?

Any help would be greatly appreciated.

Thank you in advance

  #2  
Old February 4th, 2009, 05:59 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default issue with reading the value in the subreport from report

While, it is possible to use VBA code in the Format event of the section
that contains the text box on the main report to read a total from a control
in the subreport that has already accumulated the total, you don't need code
to do this job.

If you do use code, be aware that reports are not like forms. Forms have a
current record that can be read from anywhere; reports are forward scrolling
objects where the concept of a value in the current record does not apply.

Here's the simple (and code-free) solution:
Bring the total from a subreport onto a main report
at:
http://allenbrowne.com/casu-18.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Associates" wrote in message
...
Hi,

I have been trying to make the following VB code to work but with no luck.
Wonder if anyone might be able to help me out.

Me.TotNumOfStudents = Sum([Reports]![Students Report]![StudentsPerClass])

I have a report called MasterReport which has a subreport, called
"Students
Report". What i want to do here is to be able to work out a total of
number
of students per classroo. To do this, i need to do a sum of
StudentsPerClass
that exists in the subreport, Students Report. When i run the code, it
prompts me for the value of StudentsPerClass in a Windows Dialog box.

The textbox of TotNumOfStudents is actually in the MasterReport, though.

I donot understand why it did not like it. Would it be because the
subreport
has not yet been run and therefore the MasterReport can not know the value
for the textbox TotNumOfStudents?


  #3  
Old February 5th, 2009, 04:00 AM posted to microsoft.public.access.reports
associates
external usenet poster
 
Posts: 132
Default issue with reading the value in the subreport from report

It works, Allen.

Thank you very much for your help

"Allen Browne" wrote:

While, it is possible to use VBA code in the Format event of the section
that contains the text box on the main report to read a total from a control
in the subreport that has already accumulated the total, you don't need code
to do this job.

If you do use code, be aware that reports are not like forms. Forms have a
current record that can be read from anywhere; reports are forward scrolling
objects where the concept of a value in the current record does not apply.

Here's the simple (and code-free) solution:
Bring the total from a subreport onto a main report
at:
http://allenbrowne.com/casu-18.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Associates" wrote in message
...
Hi,

I have been trying to make the following VB code to work but with no luck.
Wonder if anyone might be able to help me out.

Me.TotNumOfStudents = Sum([Reports]![Students Report]![StudentsPerClass])

I have a report called MasterReport which has a subreport, called
"Students
Report". What i want to do here is to be able to work out a total of
number
of students per classroo. To do this, i need to do a sum of
StudentsPerClass
that exists in the subreport, Students Report. When i run the code, it
prompts me for the value of StudentsPerClass in a Windows Dialog box.

The textbox of TotNumOfStudents is actually in the MasterReport, though.

I donot understand why it did not like it. Would it be because the
subreport
has not yet been run and therefore the MasterReport can not know the value
for the textbox TotNumOfStudents?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.