Refreshing a subform

J

jean

Hi

I have a Form "Terms" containing 2 subforms "Terms1" and "Terms2"

Main form "Terms" as no source

Subform "Terms1" (continuous form) is based on a table
"CommercialTerms" and contains 4 fields. One of the field is named
"Profit"

Subform "Terms2" (continuous form) is based on a query and this query
is based on the table "CommercialTerms"

When I change "Profit" on one of the record of Subforms "Terms1" I
would like to see results on Subform "Terms2"

The only way right now I can manage is with a command button on the
main form that would requery "Terms2"

I have try many things with the event "After Update" of the "Profit"
field but each time I got an error message like if routine don't want
to leave "Terms1" to requery "Terms2" Cannot find Terms2 ....

I have try to call a subroutine "Call RefreshForm" where
"RefreshForm" = DoCmd.requery "Terms2" without success.

I am sure it is easy, but I cannot find it

Thanks for helping
 
H

Hans Up

jean said:
I have try many things with the event "After Update" of the "Profit"
field but each time I got an error message like if routine don't want
to leave "Terms1" to requery "Terms2" Cannot find Terms2 ....

I have try to call a subroutine "Call RefreshForm" where
"RefreshForm" = DoCmd.requery "Terms2" without success.

As far as Access is concerned "Terms2" is a control contained in your
main form "Terms". Access doesn't even consider "Terms" to be an open
form (in the sense that you won't find it's name in the Forms collection).

Basically, Access didn't know where to find Terms2. So you have to tell
it where to find Terms2.

Try "Me!Terms2.ReQuery" in the After Update event of the Profit control
on Terms1.

Private Sub Profit_AfterUpdate()
Me!Terms2.ReQuery
End Sub

"Me" is an alias to the current form (Terms).

So, that command is equivalent to running this command in the Immediate
Window:

Forms!Terms!Term2.ReQuery
 
J

jean

As far as Access is concerned "Terms2" is a control contained in your
main form "Terms".  Access doesn't even consider "Terms" to be an open
form (in the sense that you won't find it's name in the Forms collection)..

Basically, Access didn't know where to find Terms2.  So you have to tell
it where to find Terms2.

Try "Me!Terms2.ReQuery" in the After Update event of the Profit control
on Terms1.

Private Sub Profit_AfterUpdate()
Me!Terms2.ReQuery
End Sub

"Me" is an alias to the current form (Terms).

So, that command is equivalent to running this command in the Immediate
Window:

Forms!Terms!Term2.ReQuery


Hi I have try

Private Sub Profit_AfterUpdate()
Me!Terms2.ReQuery
End Sub

and

Forms!Terms!Terms2.ReQuery


but it is not working

I thing theses solution would work if "Profit" was on the main form;
but ... it is on subform1; so I am still searching for a script that
woul update subform2 while I am making changes in subform1

Any other suggestion

thanks
 
H

Hans Up

jean said:
Private Sub Profit_AfterUpdate()
Me!Terms2.ReQuery
End Sub

and

Forms!Terms!Terms2.ReQuery


but it is not working

I thing theses solution would work if "Profit" was on the main form;
but ... it is on subform1; so I am still searching for a script that
woul update subform2 while I am making changes in subform1

Any other suggestion

I created a Terms form with Terms1 and Terms2 subforms. Terms1 is based
on table CommercialTerms. Terms2 is based on a query of
CommercialTerms. After doing this, I first thought you should try:

Private Sub Profit_AfterUpdate()
Me.Parent.Controls("Terms2").Requery
End Sub

(for the Profit control on Terms1)

However, in my version of the Terms form, I can discard the
Profit_AfterUpdate code and Terms2 still automatically (and immediately)
refreshes to display any change made to Profit on Term1.

So I'm stumped, jean. Sorry.

Hans
 

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

Similar Threads


Top