Refreshing subforms in tab control

S

Sandy

Hello -

I have a main form with a 7 tabs in a tab control.

The data I am managing is for a manufacturing work flow, so most of the data
is in one table with many fields as the work flow is linear.

I have organized the view of the data in the tab controls, using sub forms
in each tab
eg
Job details
Quote Prep
Quote Summary
Quote
PO
Requisition
etc

Some of the fields in a sub form are based on values or calculations against
fields on another sub form.

eg
=[Forms]![Main Form]![f_QuoteSummary].[Form]![OrderGrandTotal]

The challenge I am facing is that when I update the data in one tab, then
move to another, the data is not refreshing.

I have set up the following Event Procedures on the tab buttons in an effort
to solve this but it does not work consistently.

The idea was to save the record on the tab sub forms I was working on (on
MouseDown) before moving on to another tab, then refreshing the data on forms
in the new tab control (on MouseUp) before it is viewed.

Private Sub QuoteSumm_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
DoCmd.RunCommand acCmdSaveRecord
End Sub

Private Sub QuoteSumm_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me![f_QuoteSummary].Form.Requery

End Sub

The data does not always refresh - I have to click in and out of the form
before I get the new data.

Any help making this more elegant and reliable would be greatly appreciated.

regards
sandra
 
D

dch3

Create a public sub in the Main Form which refreshes all of the subforms.
Then call the sub from each of the subform's lost focus event. That should do
it.
 
S

Sandy

Thanks DC -

I have not used a public sub before so I am not sure where to put it. Do I
create this as a module?

Also, the syntax for the sub, for each sub form in each tab, would I code as
follows:

[Forms]![Main Form]![f_SubForm].Form.Requery

or do I have to reference the Tab as well?

[Forms]![Main Form]![tab control].[f_SubForm].Form.Requery

Do I do requery or refresh?

Thanks for all your help!
sandra






dch3 said:
Create a public sub in the Main Form which refreshes all of the subforms.
Then call the sub from each of the subform's lost focus event. That should do
it.

Sandy said:
Hello -

I have a main form with a 7 tabs in a tab control.

The data I am managing is for a manufacturing work flow, so most of the data
is in one table with many fields as the work flow is linear.

I have organized the view of the data in the tab controls, using sub forms
in each tab
eg
Job details
Quote Prep
Quote Summary
Quote
PO
Requisition
etc

Some of the fields in a sub form are based on values or calculations against
fields on another sub form.

eg
=[Forms]![Main Form]![f_QuoteSummary].[Form]![OrderGrandTotal]

The challenge I am facing is that when I update the data in one tab, then
move to another, the data is not refreshing.

I have set up the following Event Procedures on the tab buttons in an effort
to solve this but it does not work consistently.

The idea was to save the record on the tab sub forms I was working on (on
MouseDown) before moving on to another tab, then refreshing the data on forms
in the new tab control (on MouseUp) before it is viewed.

Private Sub QuoteSumm_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
DoCmd.RunCommand acCmdSaveRecord
End Sub

Private Sub QuoteSumm_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me![f_QuoteSummary].Form.Requery

End Sub

The data does not always refresh - I have to click in and out of the form
before I get the new data.

Any help making this more elegant and reliable would be greatly appreciated.

regards
sandra
 
S

Sandy

I am trying to get a head start on this and have gotten this far to test on a
few of the forms and their sub forms> Howver, I am missing something as this
is not working. The data updates properly from the Menu Records-> Refresh so
I know the data is OK.

Module code:

Function Run_RefreshForms(MyFormName As String)

Forms![Main Form]![f_newjob].Refresh
Forms![Main Form]![f_newjob].Form![f_JobSumm-ContactSub].Refresh

Forms![Main Form]![f_QuoteSummary].Refresh

Forms![Main Form]![f_quote].Refresh
Forms![Main Form]![f_quote].Form![f_QuoteDetails SubForm].Refresh

MsgBox "test works!"

End Function

On GotFocus at the form I am using this Event Procedure:

Private Sub Form_GotFocus()
Run_RefreshForms Me.Name
End Sub



I used the GotFocus instead of LostFocus to make sure that the form loads
the latest values, since this is a multi-user database.

Any help on fixing this code would be greatly appreciated.

thanks
sandra



Sandy said:
Thanks DC -

I have not used a public sub before so I am not sure where to put it. Do I
create this as a module?

Also, the syntax for the sub, for each sub form in each tab, would I code as
follows:

[Forms]![Main Form]![f_SubForm].Form.Requery

or do I have to reference the Tab as well?

[Forms]![Main Form]![tab control].[f_SubForm].Form.Requery

Do I do requery or refresh?

Thanks for all your help!
sandra






dch3 said:
Create a public sub in the Main Form which refreshes all of the subforms.
Then call the sub from each of the subform's lost focus event. That should do
it.

Sandy said:
Hello -

I have a main form with a 7 tabs in a tab control.

The data I am managing is for a manufacturing work flow, so most of the data
is in one table with many fields as the work flow is linear.

I have organized the view of the data in the tab controls, using sub forms
in each tab
eg
Job details
Quote Prep
Quote Summary
Quote
PO
Requisition
etc

Some of the fields in a sub form are based on values or calculations against
fields on another sub form.

eg
=[Forms]![Main Form]![f_QuoteSummary].[Form]![OrderGrandTotal]

The challenge I am facing is that when I update the data in one tab, then
move to another, the data is not refreshing.

I have set up the following Event Procedures on the tab buttons in an effort
to solve this but it does not work consistently.

The idea was to save the record on the tab sub forms I was working on (on
MouseDown) before moving on to another tab, then refreshing the data on forms
in the new tab control (on MouseUp) before it is viewed.

Private Sub QuoteSumm_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
DoCmd.RunCommand acCmdSaveRecord
End Sub

Private Sub QuoteSumm_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me![f_QuoteSummary].Form.Requery

End Sub

The data does not always refresh - I have to click in and out of the form
before I get the new data.

Any help making this more elegant and reliable would be greatly appreciated.

regards
sandra
 
D

dch3

The idea behind using the lostFocus is to requery all of the subforms after
you've updated records in the current subform. ("I'm finished working with
this subform so please update the other subforms for me.")

The proper syntax would be
[Forms]![ParentFormName]![SubformName].Form.Requery

Use the .REQUERY method instead of .REFRESH

Also you don't have to pass in the form name unless you need to.

Sandy said:
I am trying to get a head start on this and have gotten this far to test on a
few of the forms and their sub forms> Howver, I am missing something as this
is not working. The data updates properly from the Menu Records-> Refresh so
I know the data is OK.

Module code:

Function Run_RefreshForms(MyFormName As String)

Forms![Main Form]![f_newjob].Refresh
Forms![Main Form]![f_newjob].Form![f_JobSumm-ContactSub].Refresh

Forms![Main Form]![f_QuoteSummary].Refresh

Forms![Main Form]![f_quote].Refresh
Forms![Main Form]![f_quote].Form![f_QuoteDetails SubForm].Refresh

MsgBox "test works!"

End Function

On GotFocus at the form I am using this Event Procedure:

Private Sub Form_GotFocus()
Run_RefreshForms Me.Name
End Sub



I used the GotFocus instead of LostFocus to make sure that the form loads
the latest values, since this is a multi-user database.

Any help on fixing this code would be greatly appreciated.

thanks
sandra



Sandy said:
Thanks DC -

I have not used a public sub before so I am not sure where to put it. Do I
create this as a module?

Also, the syntax for the sub, for each sub form in each tab, would I code as
follows:

[Forms]![Main Form]![f_SubForm].Form.Requery

or do I have to reference the Tab as well?

[Forms]![Main Form]![tab control].[f_SubForm].Form.Requery

Do I do requery or refresh?

Thanks for all your help!
sandra






dch3 said:
Create a public sub in the Main Form which refreshes all of the subforms.
Then call the sub from each of the subform's lost focus event. That should do
it.

:

Hello -

I have a main form with a 7 tabs in a tab control.

The data I am managing is for a manufacturing work flow, so most of the data
is in one table with many fields as the work flow is linear.

I have organized the view of the data in the tab controls, using sub forms
in each tab
eg
Job details
Quote Prep
Quote Summary
Quote
PO
Requisition
etc

Some of the fields in a sub form are based on values or calculations against
fields on another sub form.

eg
=[Forms]![Main Form]![f_QuoteSummary].[Form]![OrderGrandTotal]

The challenge I am facing is that when I update the data in one tab, then
move to another, the data is not refreshing.

I have set up the following Event Procedures on the tab buttons in an effort
to solve this but it does not work consistently.

The idea was to save the record on the tab sub forms I was working on (on
MouseDown) before moving on to another tab, then refreshing the data on forms
in the new tab control (on MouseUp) before it is viewed.

Private Sub QuoteSumm_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
DoCmd.RunCommand acCmdSaveRecord
End Sub

Private Sub QuoteSumm_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me![f_QuoteSummary].Form.Requery

End Sub

The data does not always refresh - I have to click in and out of the form
before I get the new data.

Any help making this more elegant and reliable would be greatly appreciated.

regards
sandra
 
S

Sandy

Thanks again, DC, I appreciate you hanging with me on this one!

I have modified the code and called the function on the LostFocus event as
you suggested, but still no luck.

I am wondering if I am calling the funciton correctly? What is the Me.Name
part for?

Run_RefreshForms Me.Name

====================

Function Run_RefreshForms(MyFormName As String)

Forms![Main Form]![f_newjob].Form.Requery
Forms![Main Form]![f_newjob].Form![f_JobSumm-ContactSub].Form.Requery

Forms![Main Form]![f_QuoteSummary].Form.Requery

Forms![Main Form]![f_quote].Form.Requery
Forms![Main Form]![f_quote].Form![f_QuoteDetails SubForm].Form.Requery

MsgBox "test works!"

End Function

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





dch3 said:
The idea behind using the lostFocus is to requery all of the subforms after
you've updated records in the current subform. ("I'm finished working with
this subform so please update the other subforms for me.")

The proper syntax would be
[Forms]![ParentFormName]![SubformName].Form.Requery

Use the .REQUERY method instead of .REFRESH

Also you don't have to pass in the form name unless you need to.

Sandy said:
I am trying to get a head start on this and have gotten this far to test on a
few of the forms and their sub forms> Howver, I am missing something as this
is not working. The data updates properly from the Menu Records-> Refresh so
I know the data is OK.

Module code:

Function Run_RefreshForms(MyFormName As String)

Forms![Main Form]![f_newjob].Refresh
Forms![Main Form]![f_newjob].Form![f_JobSumm-ContactSub].Refresh

Forms![Main Form]![f_QuoteSummary].Refresh

Forms![Main Form]![f_quote].Refresh
Forms![Main Form]![f_quote].Form![f_QuoteDetails SubForm].Refresh

MsgBox "test works!"

End Function

On GotFocus at the form I am using this Event Procedure:

Private Sub Form_GotFocus()
Run_RefreshForms Me.Name
End Sub



I used the GotFocus instead of LostFocus to make sure that the form loads
the latest values, since this is a multi-user database.

Any help on fixing this code would be greatly appreciated.

thanks
sandra



Sandy said:
Thanks DC -

I have not used a public sub before so I am not sure where to put it. Do I
create this as a module?

Also, the syntax for the sub, for each sub form in each tab, would I code as
follows:

[Forms]![Main Form]![f_SubForm].Form.Requery

or do I have to reference the Tab as well?

[Forms]![Main Form]![tab control].[f_SubForm].Form.Requery

Do I do requery or refresh?

Thanks for all your help!
sandra






:

Create a public sub in the Main Form which refreshes all of the subforms.
Then call the sub from each of the subform's lost focus event. That should do
it.

:

Hello -

I have a main form with a 7 tabs in a tab control.

The data I am managing is for a manufacturing work flow, so most of the data
is in one table with many fields as the work flow is linear.

I have organized the view of the data in the tab controls, using sub forms
in each tab
eg
Job details
Quote Prep
Quote Summary
Quote
PO
Requisition
etc

Some of the fields in a sub form are based on values or calculations against
fields on another sub form.

eg
=[Forms]![Main Form]![f_QuoteSummary].[Form]![OrderGrandTotal]

The challenge I am facing is that when I update the data in one tab, then
move to another, the data is not refreshing.

I have set up the following Event Procedures on the tab buttons in an effort
to solve this but it does not work consistently.

The idea was to save the record on the tab sub forms I was working on (on
MouseDown) before moving on to another tab, then refreshing the data on forms
in the new tab control (on MouseUp) before it is viewed.

Private Sub QuoteSumm_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
DoCmd.RunCommand acCmdSaveRecord
End Sub

Private Sub QuoteSumm_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me![f_QuoteSummary].Form.Requery

End Sub

The data does not always refresh - I have to click in and out of the form
before I get the new data.

Any help making this more elegant and reliable would be greatly appreciated.

regards
sandra
 

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