Results 1 to 3 of 3
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    cycle thur controls on a subreport

    It must be a syntax problem (I think). But as soon as I get to the line of code to cycle thru the controls on the subreports, I get an error
    If someone could simply correct it for me (PLZ)

    With many thanks in advance



    Code:
    Public Sub ToggleProperties(rpt As Report, wFontWeight As Variant, wForeColor As Variant, wFontItalic As Variant)
        Dim ctl As Control
        For Each ctl In rpt.Controls
            Select Case ctl.ControlType
                Case acTextBox
                    If (rpt.Visible = True) Then
                        ctl.FontWeight = wFontWeight
                        ctl.ForeColor = wForeColor
                        ctl.FontItalic = wFontItalic
                    End If
                Case acSubform
    'this is the line of code that throws the error
                    Call ToggleProperties(rpt(ctl.Name), wFontWeight, wForeColor, wFontItalic)
            End Select
        Next ctl
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Well, can't refer to a subreport as a report object because they are not part of the active Reports collection. Subreports are not opened as a Report, they are opened as the SourceObject of a Container control. Same goes for subforms. The SourceObject and its controls must be referenced through the Container control name.

    The ctl.Name that line would be referencing is the Container name. Container controls do not have those properties.

    Suggest using Conditional Formatting for textboxes and comboboxes instead. The Conditional Formatting rule would reference data on the form as criteria.
    Last edited by June7; 10-01-2017 at 10:52 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    Aurgh

    For some unknown force of the universe, I just can't seem to grasp the concepts of:
    Active Reports Collections, SourceObjects, and Container Controls !!!

    None-the-less, your response is exactly enough to get me thru; ...much appreciated.

    thnx

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 12-07-2015, 07:46 PM
  2. Populate Subreport Controls Based On User Input
    By unifyzero in forum Reports
    Replies: 2
    Last Post: 06-25-2015, 08:42 AM
  3. Cycle through variables
    By Ruegen in forum Programming
    Replies: 9
    Last Post: 11-20-2014, 08:50 PM
  4. Cycle through collection
    By Ruegen in forum Programming
    Replies: 2
    Last Post: 11-19-2014, 04:50 PM
  5. Cycle Through Parameters in VBA
    By kestefon in forum Access
    Replies: 3
    Last Post: 07-10-2014, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums