Changing tab color

  • Thread starter Thread starter Gary Hull
  • Start date Start date
G

Gary Hull

I have a db that has the form Job Name

This form also has several page tabs that have sub forms on them

What I would like to do is to be able to know what sub form has data in it
without clicking on that tab

Say I have entered a record in the sub form material, I need to change the
tab color, to show that there is a record in that sub form

Thanks for your help
 
It would be very helpfull to know how to test for the existence of a a
record

You cannot change the tab color , but you can change the caption. For
 
I recently wrote code to add a magnifying glass image to tabs that have
"interesting" data. I've used this for tabs and for command buttons. The
varPictureData has the data I extracted for the magnifying glass image.
Access lets you specify images in design mode, so you could choose other
images if you wanted. This code has been used with both Access 2007 and
2003.

Private Sub ImageSet_AnyControl(ctl As Access.Control, fShowImage As
Boolean)
'Depending on the value of fShowImage, _
the specified control will have an image added or removed. _
The intended usage is to highlight controls that have "interesting" data.
'This is a private routine that does the work. _
There are control-specific public routines. _
The calling routine, generally the Form_OnCurrent, _
would use code like: TabPageImageSet Me.pageNotes, (Not IsNull(Me.notes))
Const cstrEmptyPictureText As String = "(none)"
Static abytePictureData() As Byte 'Will be initialized with the
image data
Static fIsInitialized As Boolean

'Variables for initializing the picture data
Dim varPictureData As Variant
Dim lngIndex As Long

'Initialize the pictureData to a local variable
If Not fIsInitialized Then
fIsInitialized = True

'Array function returns a variant, but it's a long integer array. _
We transfer to the required byte array below.
'This array is the image of a magnifying glass. _
It was generated by putting the image on a tab page, _
copying it to a variant which is then a byte array, _
then looping through the array and writing contents to a string
variable.
varPictureData = _
Array( _
40, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, _
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 128, 0, 0, 128, 0, 0, 0, 128, 128, 0, 128, 0,
_
0, 0, 128, 0, 128, 0, 128, 128, 0, 0, 128, 128, 128, 0, 192,
192, _
192, 0, 0, 0, 255, 0, 192, 192, 192, 0, 0, 255, 255, 0, 255, 0,
_
0, 0, 192, 192, 192, 0, 255, 255, 0, 0, 255, 255, 255, 0, _
218, 218, 218, 218, 218, 218, 218, 218, 0, 173, 173, 173, 173,
173, 173, 173, _
0, 10, 218, 218, 218, 218, 218, 218, 160, 0, 173, 173, 173, 173,
173, 173, 218, _
0, 10, 112, 0, 7, 218, 218, 173, 160, 0, 8, 136, 128, 13, 173,
218, 218, 7, _
238, 136, 136, 112, 218, 173, 167, 8, 232, 136, 136, 128, 125,
218, 208, 142, _
136, 136, 136, 136, 10, 173, 160, 136, 136, 136, 136, 136, 13,
218, 208, 136, 136, _
136, 136, 232, 10, 173, 160, 136, 136, 136, 136, 232, 13, 218,
215, 8, 136, 136, _
142, 224, 122, 173, 173, 7, 136, 142, 238, 112, 173, 218, 218,
208, 8, 136, 128, _
10, 218, 173, 173, 173, 112, 0, 7, 173, 173 _
)
'Transfer data to our static byte array
ReDim abytePictureData(UBound(varPictureData))
For lngIndex = 0 To UBound(varPictureData)
abytePictureData(lngIndex) = CByte(varPictureData(lngIndex))
Next lngIndex
End If

'Only make the assignment if we're making a change.
If fShowImage Then
If ctl.Picture = cstrEmptyPictureText Then
ctl.PictureData = abytePictureData
End If
Else
If ctl.Picture <> cstrEmptyPictureText Then
ctl.Picture = ""
End If
End If
End Sub

Public Sub TabPageImageSet(pageTab As Access.Page, fShowImage As Boolean)
'Depending on the value of fShowImage, _
the specified tab page will have an image added or removed. _
The intended usage is to highlight tabs that have "interesting" data. _
The calling routine, generally the Form_OnCurrent, _
would use code like: TabPageImageSet Me.pageNotes, (Not IsNull(Me.notes))
Call ImageSet_AnyControl(ctl:=pageTab, fShowImage:=fShowImage)
End Sub
 
Looks like I pasted the link twice in a row. I just wanted to toss it out
there that it can be done. I did so wondering as you did whether it is more
than is needed.
 
Back
Top