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!

having subform calc transfer to main form

Status
Not open for further replies.

shankbanta

Technical User
Apr 15, 2003
43
US
I have a subform that performs a calculation. Is there a way to make that calculated field write to another field in the main form? Right now the user has to transfer that information.

Thanks
 
In the after_update event of your subform control
put
Me.Parent![NameOfTheCtrlInMainForm] = Me![NameOfTheCtrlInSubForm]
 
No did not work. I mad the following assumptions:
Me.BTDENTRY(Parent)![Sectns] (NameOfTheCtrlInMainForm) = Me! [Total Sections] (NameOfTheControlInSubForm)

I first got the error: Microsoft Access Can't find the macro 'Me.'

So I placed a ! instead of the . in Me.Parent
I also tried using the word parent, switched a few things around and still did not work.


Now, this code you gave me I placed into the after_update event for the control of Total Sections of the subform. Did I do this correctly?
 
Me.BTDENTRY(Parent)![Sectns] (NameOfTheCtrlInMainForm) = Me! [Total Sections]

BTDENTRY = the name of the main form
Sectns = the name of the control in the main form
Total Sections = the name of the control in the subform

got it right?¸

if so the syntax is

[tt]Me.Parent![Sectns] = Me![Total Sections][/tt] in the After_Update event of the control [tt][Total Sections][/tt]


oh yeah I try it and it's working here, btw I assume that your form ans subform are in the same "form", I mean that to subform is not a separated window from the main form (That should work either way but ain't try the other possibility)
i'm using Access 2000

jul ^_^
 
Well, well. It is not working for me. I am using ACcess97, maybe that is the issue. Yess, all of the above assumptions are correct. In the control there is =SUM(Sections) of the subform.
 
when you say "it is not working" you mean "not working like I want" ou "not working because it doesn't compile"

(I sound like the guy in the subway ad )
jul ^_^
 
as in, I do not get an error or message and it does not copy the calculated field to the main form.

To answer a previous question, yes my subform is embedded in my main form.
 
Heh I think I see why ... when is that control is calculated? is it already calculated before you open the form?or as you open the form? if so the code don't go in the after_update... but since I don't want to mislead you and I haven't try it out and/or know the exact situation of the db .. i'll just put some wild guess from here : [ol][li]If the [Total Section] is bound to a field in a table why it isn't possible to bound the [sectns] to the same field ?!
[/li][li] You could put " =Me![NameOfTheSubForm].Form![Total Section].Value" in the default value of [sectns][/li][li] Maybe put the code I gave you previously in the (On Load Or in On Current event) of the MainForm[/li][/ol]

that's three different solution, but maybe they aren't complete


jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
If the [Total Section] is bound to a field in a table why it isn't possible to bound the [sectns] to the same field ?!

Tried this and it did not work.

But, thank you. You gave me enough to get me going. This is how it ended and worked.

Using Expression builder (while in main form) I used the loaded forms option to create:
=[SubFormName].[Form]![Total Sections]
(which is simnilar to your #2)and it worked.

Thank you so much.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top