I have a few Navigation forms - which obviously have subforms in them
Each subform processes data and I want to update each subform in a similar way.(but contained within a Navigation form)
To do this, I have put common code into a function and then have the function update the relevant subform object accordingly.
For example;
Lets say that my NavFormA has 3 tabs on it called 'Sub1', 'Sub2' and 'Sub3' (Not their real names)
Each subform has a button to launch a process.
It also has 3 labels that I want to update at various stages of the process - like this.
SubFrm1
- BtnImport
-Label1
-Label2
-Label3
SubFrm2
- BtnImport
-Label1
-Label2
-Label3
SubFrm3
- BtnImport
-Label1
-Label2
-Label3
My function looks something like this
SubFrm2 (on each Navigation form) will point to a similar function called MyFunc_SubFrm2 and so on.
This works fine if I open the form on its own, but when it is a subform on a NavForm, it breaks.
So how do I get the line 'Set FrmName = ' to pass Forms!NameOfMyNavFrm!NameOfMySubFrm
In other words, I want it to
Set FrmName = Forms!NavA!SubFrm1 or
Set FrmName = Forms!NavA!SubFrm2 or
Set FrmName = Forms!NavB!SubFrm1 or
Set FrmName = Forms!NavB!SubFrm2 or
Set FrmName = Forms!NavB!SubFrm3 or
Set FrmName = Forms!NavC!SubFrm1 etc. etc - depending on which NavForm or Subform the call is being launched from.
Hope this makes sense.
Each subform processes data and I want to update each subform in a similar way.(but contained within a Navigation form)
To do this, I have put common code into a function and then have the function update the relevant subform object accordingly.
For example;
Lets say that my NavFormA has 3 tabs on it called 'Sub1', 'Sub2' and 'Sub3' (Not their real names)
Each subform has a button to launch a process.
It also has 3 labels that I want to update at various stages of the process - like this.
SubFrm1
- BtnImport
-Label1
-Label2
-Label3
SubFrm2
- BtnImport
-Label1
-Label2
-Label3
SubFrm3
- BtnImport
-Label1
-Label2
-Label3
My function looks something like this
Code:
Function MyFunc_SubFrm1 (FrmName as form)
processData_A
FrmName!Label1.Caption = "process A name"
ProcessData_B
FrmName!Label2.Caption = "process B name"
ProcessData_C
FrmName!Label3.Caption = "All processes completed at : " & CStr(Now())
End Function
SubFrm2 (on each Navigation form) will point to a similar function called MyFunc_SubFrm2 and so on.
This works fine if I open the form on its own, but when it is a subform on a NavForm, it breaks.
Code:
Private Sub Btn_Import_Click()
Dim FrmName As Form
Set FrmName = Screen.ActiveForm
MyFunc_SubFrm2 FrmName
End Sub
So how do I get the line 'Set FrmName = ' to pass Forms!NameOfMyNavFrm!NameOfMySubFrm
In other words, I want it to
Set FrmName = Forms!NavA!SubFrm1 or
Set FrmName = Forms!NavA!SubFrm2 or
Set FrmName = Forms!NavB!SubFrm1 or
Set FrmName = Forms!NavB!SubFrm2 or
Set FrmName = Forms!NavB!SubFrm3 or
Set FrmName = Forms!NavC!SubFrm1 etc. etc - depending on which NavForm or Subform the call is being launched from.
Hope this makes sense.