How know if ControlType=acSubForm is SubReport...


@

@Alex

I can't find a solution to detect if Control.Controltype=acSubForm is
SubForm/SubReport...

The only way i find is to check for Control.Parent...

Public Sub MySub(obj As Object)
Dim ctl As Access.Control
'....... do something
'..................
For Each ctl In obj.Controls
Select Case ctl.ControlType
Case Is = acSubform
If TypeOf ctl.Parent Is Form Then
Call MySub(ctl.Form)
Else
Call MySub(ctl.Report)
End If
End Select
Next
End Function


Have i any other possibility or not...?

Tnx
@Alex
 
Ad

Advertisements

J

John Spencer

That may be the easiest way to determine the parent's type and you can make
the assumption that the sub-control matches the parent's type.

You could get the source object of the subform/subreport control and then
check for the existence of the source object in the reports collection or the
forms collection. Although, it is possible to include a subform in a report
and it is possible to have an object have the same name in both the reports
collection and the forms collection.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
@

@Alex

That may be the easiest way to determine the parent's type and you can make
the assumption that the sub-control matches the parent's type.

You could get the source object of the subform/subreport control and then
check for the existence of the source object in the reports collection orthe
forms collection.  Although, it is possible to include a subform in a report
and it is possible to have an object have the same name in both the reports
collection and the forms collection.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Hi Jhon, i agree whit all... so i mantein my idea.
Usually i do not use a SubForm in a SubReport... so my idea was for
teoretical standard development method.

Tnx
@Alex
 
Ad

Advertisements

Joined
Apr 6, 2017
Messages
1
Reaction score
0
loops all controls on report, 112 identifies report.
Dim clt As Control
'
For Each ctl In Reports!rptMain
If ctl.ControlType = 112 Then Debug.Print "subreport"

Next ctl
 

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