Forum Discussion

Tony2021's avatar
Tony2021
Iron Contributor
Sep 03, 2022
Solved

Modern Chart - adding Dynamic Chart Subtitle?

Hello Experts, 

 

I have done some research on this topic and I have not been able to find a way to  add a dynamic chart title.  I have to manually copy and paste my text to the chart's subtitle field in the chart's properties.  

 

Is there a trick to adding a dynamic subtitle?  

 

 

  • Yes - use DLookup
    Me.Chart0.ChartSubtitle = DLookup("FieldName", "Table/QueryName", "FilterCriteria")

    e.g.
    Me.Chart0.ChartSubtitle = DLookup("MyDateTime2", "t_Graphdata", "MyDataID = 4456")

7 Replies

  • Tony2021 

    You just need to read the properties sheet to see what is available:
    For example, if your chart is Chart0, then add code like this to the Form_Load event:

     

    Me.Chart0.ChartTitle = "Your Chart Title Here"
    Me.Chart0.HasSubtitle = True
    Me.Chart0.ChartSubtitle = "Your Subtitle Here"

    • Tony2021's avatar
      Tony2021
      Iron Contributor

      isladogs 

       

      ah Ok I see.  

      Could I refer to a query somehow?  

      In the below, I manually type the Chart Subtitle and it comes from a query and I would like to somehow refer to the query to avoid manually typing making it more dynamic. 

       

      • isladogs's avatar
        isladogs
        MVP
        Yes - use DLookup
        Me.Chart0.ChartSubtitle = DLookup("FieldName", "Table/QueryName", "FilterCriteria")

        e.g.
        Me.Chart0.ChartSubtitle = DLookup("MyDateTime2", "t_Graphdata", "MyDataID = 4456")

Resources