• RaymondC
  • Advanced Member Topic Starter
I am trying to change the color of the horizontal and vertical gridlines between rows of data.

If GridlineColor is the correct property then it is not working. It has no effect when changed in Access 2010.



EDIT: The property works if set in the Property Sheet dialog window but not if set via VBA. Not a big deal but F.Y.I.
Grd.GridlineColor = vbRed
Grd.GridLines = igGridLinesBoth

seem to redraw the grid lines.



The explanation why it does not work in MS Access is very simple. When we write

Grd.GridlineColor = vbRed

, actually we access a so-called "extender property" provided by MS Access but not the iGrid one (for an explanation of the concept of extender properties, you can read this MSDN article  for VB6).

As we can see from the Object browser, MS Access implements the GridlineColor  property for the Control class:

MS Access Control GridlineColor Property.png

Click to View Image135 View(s)

All controls on MS Access forms can be also referenced through the Control class, and thus they also have its common properties.

To make the iGrid property work, we simply need to access it through the helper Object  sub-property that provides us with direct access to the properties and methods of an ActiveX control:

Grd.Object.GridlineColor = vbRed