Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I pass a value from a report object to back to a form. 1

Status
Not open for further replies.

Buzzaro

MIS
May 25, 2006
3
US
The Short version...
How do I pass a value calculated in a report text box and pass it back to the form that called it. Report text boxes have no .text or .value properties.
e.g. txtOverallAvgScore.control scorce =Avg([Score])

The Long version...
I have a report that shows detailed information and then give a summary line per group, and then the final summary at the very end for the given period of time they selected. The report makes a pdf and then code writes the web page to add it the user’s downloadable reports.

We have over 50 users that have 20 or so reports; each report has this final summary I want to add to the web page.

I would like to pass the value from the final summary back to the form that called the report so I can use it to add to the code for the web page so they know the ‘big picture’ of how they are doing. The SQL goes something like this (incase it matters)...

SELECT EmpID, EmpName, Division, Section, Score, Date, FROM EmployeePerformance;

The report is grouped like this (incase it matters)...
Overall header
- Division header
-- Section header
--- Detail line
-- Section footer
- Division footer
Overall footer

On the overall group footer of the report I want to get the value from the report object txtOverallAvgScore. Since that is the number most of the people care the most about. The object doesn’t have a .value or a .text property, how can I grab it so I can pass it to back to the form.

I know I can redo the query in the program but it would take more time to do that and they are already whining and complaining about how long their reports take to run and only calculating it once would make a heck of a lot more sense.

I hope this is great question because I need a great answer (and I have searched thought this but couldn’t find the a question like this.)
 
Dont get it from the report. Create the average using a calculation on the form. You can do this in VBA using the DAvg function.

txtBox.Value = DAvg("Score","EmployeePerformance")

DAvg is
DAvg (what you want to find the average of, the table its in, the where clause if you need one)

-Pete
 
OK! OK! I should have know better... Office did it to me again...
For some reason Access2003 kept giveing me an error when I would do the txtOverallScore.text or the txtOverallScore.value saying they dont excist. shortly after writing this Access belly up on me and did a repair and compress for me...
what ever was causing that error went away and now this works... (sure now that I posted a message that makes me look like an idiot to he world)

so Both of these will work.*
[Form_Form Name].cmdEmpRpt.Tag = Me.txtOverallScore.Value
[Form_From Name].cmdEmpRpt.Tag = Me.txtOverallScore.Text

*(if access is working properly)
 
True, they work. By why get the value from the report?

-Pete
 
thanks snyperx3, good advice.

I'll be honest I have a consern is that a gremlin of code would give me a different score that what it says on the report. With my luck, that would happen at least once each batch of reports that are run.

thanks,

Jack...
 
Buzzaro,

Good idea to only have something calculate once, then use that single calculation. Much safer! And easier to maintain!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top