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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|