Right justify tab control

goodfu

Registered User.
Local time
Today, 02:18
Joined
Dec 23, 2010
Messages
140
Is there any way to make the tabs on a tab control so they are right-justified instead of left-justified?
 
Sorry to say Access wont allow you to do that, in Excel VBA forms you have the option to arrange the tabs (Page) orientation.
 
Thank you.
 
If it's really important to you, you could set the Tabbed Control's Style Property to None, then place command buttons where you want and code each button to move to the appropriate page.

Linq ;0)>
 
How do you move to a page (set focus to a control on that page)?
 
The Pages index is Zero-based, so to move to the first page

Me.YourTabControlName = 0

For the second page

Me.YourTabControlName = 1

and so forth.

To set focus to a given control on a tabbed page, you simply ignore that fact that it is on a tabbed page altogether and use the usual

ControlName.SetFocus


Linq ;0)>
 
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
 
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


Can u share a sample database file
 
Unfortunately, I have some issue with this computer that will not let me upload. But I made this a little more agnostic. As long as you name your labels with a prefix and then 0 to number of tabs it will work. You can modify the properties to make the depressed even more obvious.

But this is really all the code for the form. This is four labels. You need to change the constants to put your names in.
Code:
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
 
something like this?
attachment.php


you can add spaces to the begining of the caption.
TotalLen is a number for the max length of the tab
TCaption is the desired caption.

JustifyRight subtracts the length of the caption from the total length and adds spaces to the begining.

call it in the load event like
Code:
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")

Code:
Public Function JustifyRight(TotalLen As Integer, TCaption As String) As String

JustifyRight = Space(TotalLen - Len(TCaption)) & TCaption

End Function

Edit: Re-reading your post I see you meant the tabs themselves, not the captions.

You could use an option group wtih toggle buttons instead of labels
 

Attachments

  • rtjust.JPG
    rtjust.JPG
    13 KB · Views: 932
Last edited:
No my friend
I meed the labels itself to start from the right

Thanks for your help
 
Yeah, the tab approach is much simpler than the labels.
 

Users who are viewing this thread

Back
Top Bottom