Wake Up Subform

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Based on some good advice I received, I wanted to recode my form which has
multiple subforms on various tab controls to only activate the subforms when
the tab is selected.

I wanted to make a generic procedure to do this for the various subforms,
but am getting confused how to pass the subform identifier to the routine.
What am I doing wrong? Trying to set up something like the below, which
would wake up a subform control named "Dftlog" with a source object of
"fDFTLog".

WakeUpSubform(what do I pass here?, "fDFTLog")

Private Sub WakeUpSubform(ctl As what must this be dimensioned as?,
strSrcObj as String)
On Error GoTo Err_Routine

If Not ctl.SourceObject <> "" Then
ctl.SourceObject = strSrcObj
ctl.Visible = True
End If

Endsub
 
Chris said:
Based on some good advice I received, I wanted to recode my form
which has multiple subforms on various tab controls to only activate
the subforms when the tab is selected.

I wanted to make a generic procedure to do this for the various
subforms, but am getting confused how to pass the subform identifier
to the routine. What am I doing wrong? Trying to set up something
like the below, which would wake up a subform control named "Dftlog"
with a source object of "fDFTLog".

WakeUpSubform(what do I pass here?, "fDFTLog")

Private Sub WakeUpSubform(ctl As what must this be dimensioned as?,
strSrcObj as String)
On Error GoTo Err_Routine

If Not ctl.SourceObject <> "" Then
ctl.SourceObject = strSrcObj
ctl.Visible = True
End If

Endsub

This works for me:

'----- start of revised code -----
Private Sub WakeUpSubform(ctl As Access.SubForm, strSrcObj As String)
On Error GoTo Err_Routine

If ctl.SourceObject = "" Then
ctl.SourceObject = strSrcObj
ctl.Visible = True
End If

Exit_Point:
Exit Sub

Err_Routine:
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
Resume Exit_Point

End Sub
'----- end of code -----

And to call it:

WakeUpSubform Me!Dftlog, "fDFTLog"
 
Back
Top