I am trying to construct a graph from a query which has two columns. One for the labels and the second for the frequency of that age range. The problem is that I can't get the labels to appear on the x axis of the graph.
The code below is how I have constructed the graph:
Private Sub Form_Load()
Set m_objChart = chart.Object
chart.RowSource = ""
Select Case bleh
Case [Forms]![frmReports]!lstReports.RowSource = "Age of Alleged Victims"
graphtype = "Victims "
chart.RowSource = "qryAgesVictim"
chart.RowSourceType = "Table/Query"
Case [Forms]![frmReports]!lstReports.RowSource = "Age of Alleged Offenders"
graphtype = "Offenders "
chart.RowSource = "qryAgesOffender"
chart.RowSourceType = "Table/Query"
End Select
If chart.RowSource <> "" Then
With m_objChart
.ChartArea.Font.Size = 8
.ChartType = xlColumnClustered
.Refresh
' .Axes(xlSeriesAxis).HasTitle = False
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = graphtype + "Age"
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Caption = "Frequency"
End With
End With
End If
End Sub
The second problem is the Case statement. What I want to do is that a list box on a previous form contains all the reports in my system. when I click the graph button the graph form loads with the above code. So it checks which report is selected and uses the appropiate query to construct the graph. The problem is that it always loads the first case. So it must mean the check is incorrect.
Hope you can help on these two problems.
The code below is how I have constructed the graph:
Private Sub Form_Load()
Set m_objChart = chart.Object
chart.RowSource = ""
Select Case bleh
Case [Forms]![frmReports]!lstReports.RowSource = "Age of Alleged Victims"
graphtype = "Victims "
chart.RowSource = "qryAgesVictim"
chart.RowSourceType = "Table/Query"
Case [Forms]![frmReports]!lstReports.RowSource = "Age of Alleged Offenders"
graphtype = "Offenders "
chart.RowSource = "qryAgesOffender"
chart.RowSourceType = "Table/Query"
End Select
If chart.RowSource <> "" Then
With m_objChart
.ChartArea.Font.Size = 8
.ChartType = xlColumnClustered
.Refresh
' .Axes(xlSeriesAxis).HasTitle = False
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = graphtype + "Age"
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Caption = "Frequency"
End With
End With
End If
End Sub
The second problem is the Case statement. What I want to do is that a list box on a previous form contains all the reports in my system. when I click the graph button the graph form loads with the above code. So it checks which report is selected and uses the appropiate query to construct the graph. The problem is that it always loads the first case. So it must mean the check is incorrect.
Hope you can help on these two problems.