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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data from Access Report to Form

Status
Not open for further replies.

wdacc

Technical User
Aug 12, 2002
33
US
Dear Expert:

If I have a average of a group data on the report, how can I put it on the form and compare with other data on the form?


Thanks
 
Hi,
First, add a Label to the form. (You could use a text box, but then the user would have the capability of changing the contents, unless you set the "locked" property.)

You can set the caption property of the label to the report field, but remember that the report must be "alive". In other words, once the report is closed, the group average text box contents are gone. The best place to set the caption propery is in VBA code.

Here is what the code will look like, presuming you are using the same form to run the report:

strRptName = "rptGroupReport"
DoCmd.OpenReport strRptName, acViewPreview
lblAverage.Caption = Reports!rptGroupReport!txtAverage

When you run this report, you will see the information appear on the report. If you minimize this report and jump back to the form, you will see the value from the report.

You can do comparisons on this object with regular VBA code, e.g.,
If lblAverage > txtUserInput Then
MsgBox "The average found on the report is greater than your input"
End If

If this tip has been helpful, be sure to click on the "Mark this post as a helpful/expert post!".

Randy Smith
California Teachers Association
 
WDACC,

Move any calculations to the query behind the report. Then either use that query for the form or copy and paste the relevant field into the query behind the form.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top