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

How do I make a control based on a DSUM value? 3

Status
Not open for further replies.

ov3rdr1ve

IS-IT--Management
Oct 20, 2004
32
US
I have this on my form in an unbound control... it works fine, but the answer this provides needs to be in a bound control... where in the control would I put this?

=DSum("TrainingHours1","tblMembers")+DSum("TrainingHours2","tblMembers)


Thanks
od~
 
You cannot put the expression into the control and keep it as a bound control.
You need to look for an event, either the afterupdate event for another control or the beforeupdate event for the form itself and use code to set the value.

me.mycontrolname = DSum("TrainingHours1","tblMembers")+DSum("TrainingHours2","tblMembers)


 
I already have a control on the form that has the correct answer with this in the control source

=DSum("TrainingHours1","qryMembers")+DSum("TrainingHours2","qryMembers")


Is there anyway to just make the bound control that value?

I tried what you said in the above, but it is not updating my bound control?

This is what I have in the after update of the control performing the math

Me.Text239 = DSum("TrainingHours1", "qryMembers") + DSum("TrainingHours2", "qryMembers")

Thanks for helping!
od~
 
Actually... here is what I am trying to do.

I have 4 controls on my form...

Field1=2
Field2=2
Field3=2
Field4=3

total =9

I am trying to get a total of the 4 controls and get that new control bound as well... this way I can track the total of all 4 fields per record.

Any Ideas?

Thanks
od



 
Why would you want to put calculated data in a bound control? Calculated data should not be stored in the table.


Randy
 
And I agree with you... how then would you make the data only pertinent to the record that is shown?

Right now the only way I know how to do that is to force the control to be bound to the record itself?

thanks
od
 
By adding the calculated field in the underlaying query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How about in the OnCurrent event.

The control should recalculate whenever you change one of the values in the other fields. If not, put something like me.YourControlName.recalculate in the AfterUpdate event of the other controls.


Randy
 
Thanks guys, I think that gets me exactly where I need to go!

THANKS!!
od~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top