Results 1 to 3 of 3
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Setting properties while Looping through ControlS


    Charts again. I have 6 (so far) chart objects on a single form. Depending on the option selected I have been using a Select Case statement and explicitly hiding or showing each chart. It runs something like this.

    Code:
    Case 1
      Chart1.visible = True
      Chart2.visible = False
      Chart3.visible = False
      Chart4.visible = False
      Chart5.visible = False
      Chart6.visible = False
    Case 2
      Chart1.visible = False
      Chart2.visible = True
      Chart3.visible = False
      Chart4.visible = False
      Chart5.visible = False
      Chart6.visible = False
    and so on. I'm trying to build a better mousetrap, but I'm stuck. Here's what I got so far.

    Code:
        
    Public Sub HideCharts(ChartID As Integer)
        Dim ctl As Control
        
            For Each ctl In Forms!frm_Chart
    
    ' ControlType captured via MsgBox       
    ' MsgBox ctl.ControlType
                
                If ctl.ControlType = 113 Then
                    If DLookup("[Graph]", "tblReports", Me.fraReports & " = [Report_ID] ") = ctl.Name Then
                        ctl.Visible = True
                    Else
                        ctl.Visible = True
                    End If
            End If
    
            Next ctl
        
    End Sub
    This works just fine, but I don't know how to turn the visible property on and off. ctl.Visible does not work. I can't see past this. I know someone knows and I think I know who it might be, but I'll take on all comers.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Code:
                    If DLookup("[Graph]", "tblReports", Me.fraReports & " = [Report_ID] ") = ctl.Name Then
                        ctl.Visible = True
                    Else
                        ctl.Visible = True
                    End If
    Not really sure what you are doing but surely one of the True's should be False
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    The real problem was the error I was getting when I tried to set the property. Of course now it works flawlessly.

    I guess I found one of those thousand ways to screw this up. Works great now.

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

Similar Threads

  1. Setting db properties with autoexec routine
    By bdaniel in forum Programming
    Replies: 10
    Last Post: 07-17-2014, 12:43 PM
  2. setting values of multiple controls
    By desimoreno in forum Forms
    Replies: 9
    Last Post: 12-14-2011, 02:54 PM
  3. Replies: 2
    Last Post: 09-29-2011, 12:50 PM
  4. Setting Field Properties for Numbers
    By Tim Hardison in forum Access
    Replies: 1
    Last Post: 12-09-2009, 06:47 AM
  5. Setting combo box properties
    By rathfam4 in forum Programming
    Replies: 1
    Last Post: 12-28-2005, 02:27 AM

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