PDA

View Full Version : Delete column in chart with Null value



kc1
03-25-2012, 03:05 PM
Hi,

I have a column chart based on a query. My query by design holds NULL values, so that I can display a list of names in the chart legend, even if there is no data against a name.

However, now of course my chart has an empty column on the left hand side.

Is there anyway of writing VBA to delete this empty column? I am no good with VBA, but thinking of an IfThenElse, i.e. If column Is Null Then delete it, Else display column?

I feel as though this must be possible, but have no idea where to start.

Thanks.

kc1
03-25-2012, 04:36 PM
Ok, I have found this code, but it is obviously for Excel. If anyone is able to help me convert it to Access, I'd really appreciate it:

Dim isEmptySeries As Boolean
For Series = 1 To .SeriesCollection.Count
.SeriesCollection(Series).ApplyDataLabels Type:=xlDataLabelsShowValue, AutoText:=True, LegendKey:=False
isEmptySeries = True

For i = 1 To .SeriesCollection(Series).points.Count
If .SeriesCollection(Series).points(i).DataLabel.Text = 0 Then
.SeriesCollection(Series).points(i).HasDataLabel = False
Else
isEmptySeries = False
.SeriesCollection(Series).points(i).DataLabel.Font.Size = 16
End If
Next i

If isEmptySeries Then
.SeriesCollection(Series).Delete
End If

Next Datenreihe

Thanks.