summing on subform and form

B

Betsy

this seemed so easy when I first started, but everything I tried has not
worked.

I have a database with a form: form1 and a subform: subform1
the subforms are connected to the form by the SchoolID
each school form will have a subform for each month.
the subforms contain many numbers and calculations which seem for the moment
to be working. I have a total field on each subform which I will need to sum
and add to the parent form as a grand total. since I cannot SUM calculated
fields I figured I would just pass the value into another field on the
subform that I could then SUM.

Currently I have built andexpression in the AFTER UPDATE field that says:

Me![subform1].Form![new ref] = Me![subform1].Form![tot ref]

This will not pass the value to the new_ref field.
then I figured I'd add some code to the field on the form that says:

Me!Referrals_to_date = [subform1].Form![new_ref]


I haven't tried this yet as i can't get the first code to work, but would
that be the way to go?
 
S

Steve Schapel

Betsy,

When you are talking about using code on the After Update event, it
seems to me from what you have told us so far that you are about the
After Update event of a control on the subform1 subform... am I right?
If so, the syntax Me![subform1] will be wrong, because "Me" already
refers to subform1, and subform1 doesn't have a subform named
subform1... if you catch my drift. Anyway, I may be off track here,
because I can't quite understand what you are trying to do, and I can't
see the point of allocating the value of a control on a form or subform
to another control on the form or subform.

If by "school form will have a subform for each month" you mean you will
have separate subforms for each month, then this would also, on the face
of it, seem to be a bad idea.

Maybe this will help... You can put an unbound textbox on the main
form, and in the Control Source enter the equivalent of this:
=[subform1]![tot ref]

And if you had 2 subforms, each with a [tot ref] control, then you can
do like this in the textbox on the main form:
=[subform1]![tot ref]+[subform2]![tot ref]

In other words, if I get the gist of what you want, then using code is
probably not applicable.
 
B

Betsy

Thanks for your help! You make a lot of sense and I can follow most of your
advise. I like your solution, unfortunately [tot ref] is a calculated field
therefore I can't just pass it on to the form as is. I need another way.
This seems to be the sticking point and why I was trying to use code to get
it there.

Any other suggestions?

Betsy


Steve Schapel said:
Betsy,

When you are talking about using code on the After Update event, it
seems to me from what you have told us so far that you are about the
After Update event of a control on the subform1 subform... am I right?
If so, the syntax Me![subform1] will be wrong, because "Me" already
refers to subform1, and subform1 doesn't have a subform named
subform1... if you catch my drift. Anyway, I may be off track here,
because I can't quite understand what you are trying to do, and I can't
see the point of allocating the value of a control on a form or subform
to another control on the form or subform.

If by "school form will have a subform for each month" you mean you will
have separate subforms for each month, then this would also, on the face
of it, seem to be a bad idea.

Maybe this will help... You can put an unbound textbox on the main
form, and in the Control Source enter the equivalent of this:
=[subform1]![tot ref]

And if you had 2 subforms, each with a [tot ref] control, then you can
do like this in the textbox on the main form:
=[subform1]![tot ref]+[subform2]![tot ref]

In other words, if I get the gist of what you want, then using code is
probably not applicable.

--
Steve Schapel, Microsoft Access MVP
this seemed so easy when I first started, but everything I tried has not
worked.

I have a database with a form: form1 and a subform: subform1
the subforms are connected to the form by the SchoolID
each school form will have a subform for each month.
the subforms contain many numbers and calculations which seem for the moment
to be working. I have a total field on each subform which I will need to sum
and add to the parent form as a grand total. since I cannot SUM calculated
fields I figured I would just pass the value into another field on the
subform that I could then SUM.

Currently I have built andexpression in the AFTER UPDATE field that says:

Me![subform1].Form![new ref] = Me![subform1].Form![tot ref]

This will not pass the value to the new_ref field.
then I figured I'd add some code to the field on the form that says:

Me!Referrals_to_date = [subform1].Form![new_ref]


I haven't tried this yet as i can't get the first code to work, but would
that be the way to go?
 
B

Betsy

Never mind! I found a typo and your solution DID work. thank you very much!

Betsy said:
Thanks for your help! You make a lot of sense and I can follow most of your
advise. I like your solution, unfortunately [tot ref] is a calculated field
therefore I can't just pass it on to the form as is. I need another way.
This seems to be the sticking point and why I was trying to use code to get
it there.

Any other suggestions?

Betsy


Steve Schapel said:
Betsy,

When you are talking about using code on the After Update event, it
seems to me from what you have told us so far that you are about the
After Update event of a control on the subform1 subform... am I right?
If so, the syntax Me![subform1] will be wrong, because "Me" already
refers to subform1, and subform1 doesn't have a subform named
subform1... if you catch my drift. Anyway, I may be off track here,
because I can't quite understand what you are trying to do, and I can't
see the point of allocating the value of a control on a form or subform
to another control on the form or subform.

If by "school form will have a subform for each month" you mean you will
have separate subforms for each month, then this would also, on the face
of it, seem to be a bad idea.

Maybe this will help... You can put an unbound textbox on the main
form, and in the Control Source enter the equivalent of this:
=[subform1]![tot ref]

And if you had 2 subforms, each with a [tot ref] control, then you can
do like this in the textbox on the main form:
=[subform1]![tot ref]+[subform2]![tot ref]

In other words, if I get the gist of what you want, then using code is
probably not applicable.

--
Steve Schapel, Microsoft Access MVP
this seemed so easy when I first started, but everything I tried has not
worked.

I have a database with a form: form1 and a subform: subform1
the subforms are connected to the form by the SchoolID
each school form will have a subform for each month.
the subforms contain many numbers and calculations which seem for the moment
to be working. I have a total field on each subform which I will need to sum
and add to the parent form as a grand total. since I cannot SUM calculated
fields I figured I would just pass the value into another field on the
subform that I could then SUM.

Currently I have built andexpression in the AFTER UPDATE field that says:

Me![subform1].Form![new ref] = Me![subform1].Form![tot ref]

This will not pass the value to the new_ref field.
then I figured I'd add some code to the field on the form that says:

Me!Referrals_to_date = [subform1].Form![new_ref]


I haven't tried this yet as i can't get the first code to work, but would
that be the way to go?
 
S

Steve Schapel

Hi Betsy,

Glad to see you have it working now, as otherwise I would not have
understood what you meant by:
... unfortunately [tot ref] is a calculated field
therefore I can't just pass it on to the form as is.
 
B

Betsy

WEll, it wouldn't work so I thought it was because it was a calculated
field.....Shows what I know :)

thanks again. I'm moving along now.
Steve Schapel said:
Hi Betsy,

Glad to see you have it working now, as otherwise I would not have
understood what you meant by:
... unfortunately [tot ref] is a calculated field
therefore I can't just pass it on to the form as is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top