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

Summarized field in form footers 1

Status
Not open for further replies.

si013

MIS
Jul 18, 2003
9
GB
Can anyone help. I currently have a Subform (datasheet view) and i have three field summarizing the data,
=count("*")
=avg([turnaround])
=sum([turnaround])

Once the form has been refreshed, i reference the three fields within VBA and i assign the values to three variables. But whenever the event is started, the variables are always set to 0. If i put a break point in the code and F8 through it, it will assign the values correctly.

Any ideas?
 
Let's see your code. [worm]

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
dim TotalDone as long
dim TurnAverage as long
dim TotalAverage as long

TotalDone = [frmgrid].form![txtTotalDone]
TotalAverage = [frmgrid].form![txtTotalAverage]
TurnAverage = [frmgrid].form![txtTurnAverage]
 
Are the variables dimensioned at module level?

Code:
Option Compare Database
Option Explicit

'Module-level declarations

Dim TotalDone as Long
Dim TurnAverage as Long
Dim TotalAverage as Long 


Private Sub Form_Current()
 
  TotalDone = [frmgrid].form![txtTotalDone]
  TotalAverage = [frmgrid].form![txtTotalAverage]
  TurnAverage = [frmgrid].form![txtTurnAverage]

End Sub


VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
I would put textboxes on the main form and set their ControlSource properties to the textboxes on the subform.

If you don't want to see them just set the Visible property to false. That way they will always be current even when the user makes changes to the subform data.

You can get at the totals by referring to the Forms![MainForm]![txtTotalDone] from just about anywhere.

In the main form you can use the textboxes just like variables:
Code:
 Msgbox "There are " & [txtTotalDone] & " jobs done."


VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top