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

CAn you get the value in a text box to equal the sum of a sub form?

Status
Not open for further replies.

jjme88

Programmer
Dec 28, 2007
58
GB
Hi,

I want to display in the text box on my main form the sum of the result of another text box that is on a sub form. The sub form is basically a datasheet that shows all transactions.

on the man form i want to show sub totals of some of the columns?

hope that makes sense and someone can point me in the right direction.

jj
 
This maybe a sledgehammer method (but I've got similar running easily):

1. On your form - make the value of the text box a function eg MyFunction(ThisRecord).

2. Write a VBA function (eg MyFunction (ThisRecord as integer) ) to calculate (or look up) the required value. You could look up a value calculated in a view for example

3. You might need to add an appropriate 'Refresh' statement to the form so that the value gets re-calculated when required

I've done something similar using Labels (rather than text boxes) & the caption of the label is changed (& repainted) when the contents of the text box on the sub-form is changed (After Update).
 
use this:

Me.MainFormTextBox = Me.subFormName!sumTextBox

Then set the control source of the subform textbox to the sum value:

= Sum([fieldName])

.....
I'd rather be surfing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top