Updating subform

  • Thread starter Thread starter Annelie
  • Start date Start date
A

Annelie

I have a subform, which come from the table Budgets. I use this form to
enter the amounts for the budget. I created a subform to this form, which
come from a query, which calculates Budget vs. Actual and displays the
resulting differences between budget and actual. form with the subform.

On the main form which comes from the Jobs table, I call up the job and
enter the figures for the budget in the subform.
After I am finished entering the budget figures, I would like to results to
show in that sub-subform. But saving the subform and refreshing the
sub-subform does not work. Only after I exit the current data and recall the
job, will the sub-subform show the result.
How can I get the results without having to exit.
Annelie
 
I'm not exactly sure how/what/when you are trying to see the results, but
try requerying the data on the afterupdate event of the subform or a control
on your subform:

Private Sub Form_AfterUpdate()
Forms!frmMainForm!frmSubform.Form.Requery
End Sub
 
I am confused. I have tried all combinations of forms, but I keep getting
the error message the "field" subformName cannot be found.
Mainform is FrmJobs2
1st subform is FrmBudget
2nd Subform is FrmBudgetsvsActual (this is the form which needs to be
refreshed)
..
Can you tell me what I should put on the requery and which form should get
the refresh button?
Perhaps I should make FrmBudgetvsActual a subform of FrmJobs2 instead of
FrmBudgets?
Annelie
 
Annelie, I assume that you have changed "frmMainForm" and "frmSubForm" that
I provided in the example to the "Actual" names of your main and subform
names. If you place a button on your main form set the click event to
something like this.

Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click

DoCmd.Save

'If the subform is directly on your main form
Me![FrmBudgetsvsActual].Form.Requery

'If your subform is nested in the subform on your main form
Me![FrmBudget].Form![FrmBudgetsvsActual].Form.Requery

Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click

End Sub
 
Back
Top