Public Sub depressLabel(intLabel As Integer)
Dim lblCount As Integer
Dim i As Integer
lblCount = Me.tbCtrl1.Pages.Count
For i = 1 To lblCount
With Me.Controls("lbl" & i)
'Flat and unBold
.SpecialEffect = 0
.FontBold = False
.FontUnderline = False
.FontItalic = 0
.BorderStyle = 0
End With
Next i
With Me.Controls("lbl" & intLabel)
'Sunken Bold
.SpecialEffect = 2
.FontBold = True
.FontUnderline = True
.FontItalic = True
End With
End Sub
I have a tab control set up like this with each label named "lbl1", "lbl2" ..... On the onclick event of the label you call the depresslabel event to format the labels to make it look like you pressed the label
Code:Public Sub depressLabel(intLabel As Integer) Dim lblCount As Integer Dim i As Integer lblCount = Me.tbCtrl1.Pages.Count For i = 1 To lblCount With Me.Controls("lbl" & i) 'Flat and unBold .SpecialEffect = 0 .FontBold = False .FontUnderline = False .FontItalic = 0 .BorderStyle = 0 End With Next i With Me.Controls("lbl" & intLabel) 'Sunken Bold .SpecialEffect = 2 .FontBold = True .FontUnderline = True .FontItalic = True End With End Sub
Private Sub Form_Load()
depressLabel 0
End Sub
Private Sub lbl0_Click()
depressLabel 0
End Sub
Private Sub lbl1_Click()
depressLabel 1
End Sub
Private Sub lbl2_Click()
depressLabel 2
End Sub
Private Sub lbl3_Click()
depressLabel 3
End Sub
Public Sub depressLabel(PageNumber As Integer)
Dim lblCount As Integer
Dim i As Integer
Dim tbCtrl As Access.TabControl 'Your Name here
Const TabControlName = "tbCtrl1" ' Name of your tab control
Const Prefix = "lbl" 'Need to number your labels 0 - N. I used a prefix of 'lbl but you can use
'whatever you want
Set tbCtrl = Me.Controls(TabControlName)
tbCtrl.Value = PageNumber 'Page numbers and labels are 0-1
lblCount = tbCtrl.Pages.Count 'Assume you have a numbered label for each page
For i = 0 To lblCount - 1
'The labesls used for simulating tabs are 'lbl0','lbl1'...
With Me.Controls(Prefix & i)
' Flat and unBold
.SpecialEffect = 2
.FontBold = False
.FontUnderline = False
.FontItalic = 0
.BorderStyle = 0 '
'Add more properties to look not pressed
End With
Next i
'Format for depressed control
With Me.Controls(Prefix & PageNumber)
'Sunken Bold
.SpecialEffect = 1
.FontBold = True
.FontUnderline = True
.FontItalic = True
'Add more properties to look depressed
End With
End Sub
Me.TabCtl3.Pages(0).Caption = JustifyRight(15, "Page 1")
Me.TabCtl3.Pages(1).Caption = JustifyRight(15, "Page 2")
Me.TabCtl3.Pages(2).Caption = JustifyRight(15, "Page 3")
Public Function JustifyRight(TotalLen As Integer, TCaption As String) As String
JustifyRight = Space(TotalLen - Len(TCaption)) & TCaption
End Function
heres an example