By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,282 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,282 IT Pros & Developers. It's quick & easy.

triggering a value to be passed from a control on a subform to a parent form

P: n/a

Hi all,
A subForm control, txtTotalSubForm contains a total from one of the fields
on this subForm . The mainForm contains a combo, myCombo which filters, and
updates the details on the subForm. I want this update to pass the value in
txtTotalSubForm to a control txtMainForm, on the main form. Ive tried using
the parent property, but this is not adequate since I must click onto the
subform to trigger it (on current event of the subform).

The code i tried for the update of the myCombo is as follows

----------------------------------------
Private Sub myCombo_AfterUpdate()
Me.Controls("MySubForm").Requery
Me.Refresh

Me.myMainFormTxtBox = Me.mySubform.Controls("mySubformTotalControl")
End Sub

----------------------------------------

I know the last line works, since it works from a button, after i've
updated, but not from the combo box update.
Is there some kind of timing issue that im missing. Its like calling on this
before the data is updated?

Any help/Advice would be most welcome.

Gerry Abbott

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Gerry,
I would try to requery the txtTotalSubForm before your last line.

Arno R

"Gerry Abbott" <pl****@ask.ie> schreef in bericht news:Kj*******************@news.indigo.ie...

Hi all,
A subForm control, txtTotalSubForm contains a total from one of the fields
on this subForm . The mainForm contains a combo, myCombo which filters, and
updates the details on the subForm. I want this update to pass the value in
txtTotalSubForm to a control txtMainForm, on the main form. Ive tried using
the parent property, but this is not adequate since I must click onto the
subform to trigger it (on current event of the subform).

The code i tried for the update of the myCombo is as follows

----------------------------------------
Private Sub myCombo_AfterUpdate()
Me.Controls("MySubForm").Requery
Me.Refresh

Me.myMainFormTxtBox = Me.mySubform.Controls("mySubformTotalControl")
End Sub

----------------------------------------

I know the last line works, since it works from a button, after i've
updated, but not from the combo box update.
Is there some kind of timing issue that im missing. Its like calling on this
before the data is updated?

Any help/Advice would be most welcome.

Gerry Abbott


Nov 13 '05 #2

P: n/a
Sorry, that does not work for me.

Thanks for the quick reply.
Added the line as advised (see code below). Still no change.
----------------------------------------
Private Sub myCombo_AfterUpdate()

Me.Controls("MySubForm").Requery
Me.MySubform.controls("txtTotalSubForm")
Me.Refresh

Me.myMainFormTxtBox = Me.mySubform.Controls("mySubformTotalControl")
End Sub

----------------------------------------

if I remove the requery then it updates the txt box. But it wont run the
filter.
So once the requery and the assignment are in the same module, it wont work.
Could probably get round this with and sql statement, but thought there
would be an easy way.
Im sure that im missing something simple here.
Any more Advice ?

Gerry Abbott
Nov 13 '05 #3

P: n/a
> Private Sub myCombo_AfterUpdate()

Me.Controls("MySubForm").Requery
Me.MySubform.controls("txtTotalSubForm")
Me.Refresh

Me.myMainFormTxtBox = Me.mySubform.Controls("mySubformTotalControl")
End Sub
Gerry,
I don't see the requery in your new code ... Typo?
Should be: Me.MySubform.controls("txtTotalSubForm").Requery <<====
However it would not surprise me if it won't work also...
I also recall having these issues sometimes. (Refresh-Repaint-DoEvents, nothing works 'sometimes')
Could probably get round this with and sql statement, but thought there
would be an easy way.

If you can't work it out I would go for the sql-option.
Maybe even in this case I would go for the sql-option right away.
If you rely on a calculated control you never know when Access is ready...

Arno R
Nov 13 '05 #4

P: n/a
Yes Arno, Typo in the mail only (unfortunately)
U know it would give me a big error if i left it out in the code.

Private Sub myCombo_AfterUpdate()

Me.Controls("MySubForm").Requery
Me.MySubform.controls("txtTotalSubForm").Requery
Me.Refresh

Me.myMainFormTxtBox = Me.mySubform.Controls("mySubformTotalControl")
End Sub

Yeah, Ive run into this problem before.
For the moment, until i get a better solution, ive got a big 'calculate'
button on the form.
(Im not that happy with it, but there you go)

I'll get a better solution if i've time left at the end of the project...
(or unless some person much wiser than I, can supply me a magical
solution.......)

Gerry.
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.