Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Setting SSTab1.Tab in code

Setting SSTab1.Tab in code

I have a Form1, and placed SSTab1 on it (with default 3 Tabs)
on very first Tab (Tab 0) I placed Label1

I have this very simple code:


Option Explicit

Private Sub Form_Load()
SSTab1.Tab = 1
SSTab1.Tab = 0
End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
If SSTab1.Tab = 0 Then
    Label1.BackColor = vbRed
End If
End Sub 

What I want is: no matter which Tab is selected at design time, I want to go thru SSTab1_Click event on Form_Load. Why? There are certain settings I have in SSTab1_Click event and I want first Tab (tab 0) to be always selected when Form starts.

The interesting part here is:
If during design time I select second tab (Tab 1) (or any other tab but Tab 0) and run my code, SSTab1.Tab = 0 in Form_Load 'kicks in' and Tab 0 is selected and my label is red. Great.

If during design time I select first tab (Tab 0) and run my code, code in Form_Load is 'ignored' and my label is black, not red. sad

So I have to bery careful to save my Form with Tab1 or 2 selected in order for my Form to work the way I want.

What's going on?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Setting SSTab1.Tab in code

Why don't you just call the click event yourself instead of relying on the event?


Private Sub Form_Load()

SSTab1.Tab = 0
Call SSTab1_Click(0)

End Sub 

Microsoft SQL Server MVP
My Blogs
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom

RE: Setting SSTab1.Tab in code

Works great. Thank you George smile

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Setting SSTab1.Tab in code

Or put the code currently contained in SSTab1_Click into a Private Sub and call that Sub from Form_Load and SSTab1_Click.
Some frown on calling event procedures directly although I confess I am a serial offender...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close