Setting one 'global' font size for chart data labels (1 Viewer)

Alc

Registered User.
Local time
Today, 17:34
Joined
Mar 23, 2007
Messages
2,407
I have a bar chart on a report. The number of different bars that have to fit onto the page mean that I want to set the font size for all data labels to 7. I can click on them one at a time and change it, but is there some 'global' setting for the chart as a whole that I can set? If so, where is it?

Thanks in advance.
 

Sess

Registered User.
Local time
Today, 14:34
Joined
Jan 4, 2010
Messages
74
The only tricks I know of so far are these two.
In design if you click on the label in the toolbox, before you place the label you can change the default settings so all the subsequent labels you place will have that as an initial setting for all the labels.
If you use the wizard to build and go back to edit then CtrlA selects everything and use shift and click to discount anything you do not want to change or the stuff that is not a label.
 

Alc

Registered User.
Local time
Today, 17:34
Joined
Mar 23, 2007
Messages
2,407
Thanks for that.

Unfortunately, the chart was created using the wizard and when viewed in design mode only the first thrity or so labels are visible. I've tied changing all of those to a smaller font, but as soon as extra rows are created, the font for those reverts to the larger size.
 

ChrisO

Registered User.
Local time
Tomorrow, 08:34
Joined
Apr 30, 2003
Messages
3,202
Something to try: -

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    With Me.NameOfGraph.Axes(1).TickLabels.Font
        .Size = 7
        .Name = "Arial"
        .FontStyle = "Normal"    [color=green]'   "Bold Italic"[/color]
        .Color = vbRed
    End With

End Sub

Hope that helps.
 
Last edited:

Alc

Registered User.
Local time
Today, 17:34
Joined
Mar 23, 2007
Messages
2,407
Thanks very much for that. Definitely looks promising.

As is his wont, my manager now has me working on something completely different. I shall get back to the report asap and let you know how I get on.
 

guzintaz

New member
Local time
Today, 15:34
Joined
May 8, 2020
Messages
1
Here's a solution that worked for me. Hopefully others find this useful :)

My issue: Font size for data labels on histogram bars inconsistent. Data label font size for "first" bar correct (set in the properties). Data label font size for remaining bars incorrect (not the same as the first bar).
Using MS Access 2016

Solution: VBA in the Detail_Format section of the Report. The hardest part was figuring out how to get a pointer to the chart (graph) object. Turns out a chart in MS Access is a Microsoft Graph object, so you have to include the Microsoft Graph nn.n Object Library in Tools->References. The MS doc'n for this is poor. Anyway, once you figure out how to get the pointer to the object, it's fairly straight-forward from there.

In the sub below, NameOfTheChartInYourReport is whatever name you gave the chart in your report


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

' There are some oddities when using multi-bar graphs, most notably inconsistent Font sizes
' The code here overcomes this issue
' Note: the Microsoft Graph library must be included in the Tools->References

Dim objChart As Graph.Chart
Dim objChartSeries As Graph.Series
Dim objSeriesDataLabel As Graph.DataLabel

Set objChart = NameOfTheChartInYourReport.Object ' Get a pointer to the chart object in the report

' Loop through all of the Series in the Chart
For Each objChartSeries In objChart.SeriesCollection
' Loop through all of the DataLabels in the Series
For Each objSeriesDataLabel In objChartSeries.DataLabels
objSeriesDataLabel.Font.Size = 8
Next objSeriesDataLabel
Next objChartSeries

' Change the Legend font color to Blue
With objChart
.Legend.Font.Color = vbBlue
End With

End Sub
 

Avoraightu

New member
Local time
Today, 15:34
Joined
Mar 5, 2020
Messages
28
I am currently looking for the same solution, this one looks good but I get a run-time error '438'

Set objChart = Chart463.Object

Object doesn't support this property or method
 

Users who are viewing this thread

Top Bottom