×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

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

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).   

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

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close