How to trigger Current event in subform

  • Thread starter Thread starter Peter Hibbs
  • Start date Start date
P

Peter Hibbs

Access 2003

I have a main form (frmSuppliers).
On this form I have a tab control (tabSupplier).
On the first page of the tab control I have a subform (frmProducts).

The main form is bound to table tblSuppliers (via a query) and the
subform is bound to table tblProducts (also via a query). Both forms
are linked together on field SupCode.

In the Current event of the subform (frmProducts) I have some code
which recalculates the values of several fields. What I want to do is
when the user clicks on Page 0 of the Tab control on the main form I
want to trigger the Current event of the subform so that the
calculations are done again. Something like :-

Private Sub tabSupplier_Change()

If tabSupplier = 0 Then
'trigger Forms!frmSuppliers!frmProducts!Current()
End If

I know I could write a routine in a Module and call the routine from
the main form but there are quite a few fields to be changed so it
gets a bit messy.

Is there any way to do this?

TIA

Peter Hibbs.
 
Access 2003

I have a main form (frmSuppliers).
On this form I have a tab control (tabSupplier).
On the first page of the tab control I have a subform (frmProducts).

The main form is bound to table tblSuppliers (via a query) and the
subform is bound to table tblProducts (also via a query). Both forms
are linked together on field SupCode.

In the Current event of the subform (frmProducts) I have some code
which recalculates the values of several fields. What I want to do is
when the user clicks on Page 0 of the Tab control on the main form I
want to trigger the Current event of the subform so that the
calculations are done again. Something like :-

Private Sub tabSupplier_Change()

    If tabSupplier = 0 Then
        'trigger Forms!frmSuppliers!frmProducts!Current()
    End If

I know I could write a routine in a Module and call the routine from
the main form but there are quite a few fields to be changed so it
gets a bit messy.

Is there any way to do this?

TIA

Peter Hibbs.

Peter,
Try this from your example.

Private Sub tabSupplier_Change()

If tabSupplier = 0 Then
'trigger Forms!frmSuppliers!frmProducts!Current()
Call Forms!frmSuppliers!frmProducts!Form_Current()
End If

End Sub

HTH
Pete
 
Pete,

Sorry, didn't work. Whole line shows up in red when entered and does
not compile. Any other ideas?

Peter Hibbs.
 
Assuming that fsubProducts is the name of the subform control:

Private tabSupplier_Change()

If TabSupplier = 0 Then
Call Me.fsubProducts.Form.Form_Current
End If

You will need to remove the Private keyword from the subform's Current
event.
 
Bruce,

Excellent, that seems to work fine. Thanks very much, saved me a lot
of hassle.

Peter Hibbs.
 
Glad to help. I wrestled with something of the sort at one time before my
searching led me to learn that the called event can't be Private. I tend
not to call events, but rather to use functions, because I may want to add
something to the event later, which may mean that when I call it I get
unwanted results.
 
Back
Top