By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,778 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,778 IT Pros & Developers. It's quick & easy.

Page OnClick event

100+
P: 553
I am having difficulty in doing this.

If a page on a Tab Control is clicked
Then do something

I mean page by not the whole page but when you switch from one page to another on the Tab control (The small rectangle with page name on).

I have tried this and many other methods, but dont work :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Page30_Click()
  2.     MsgBox "Page 30 clicked"
  3. End Sub
  4.  
Help please
Jul 27 '07 #1
Share this Question
Share on Google+
2 Replies


missinglinq
Expert 2.5K+
P: 3,532
The Click event of a tabbed page refers to the clicking on the actual page, what you would think of as the "background" of the page, not to the tab at the top that is used to switch from page to page. To accompish what you want to do, requires a little diddling!

In Design View Click on Page 30 and place a textbox on it; name it DummyTextBox.

Goto Properties - Events then click to the right of the On Got Focus event and select Code Builder. When the appropriate sub comes up place this code in it MsgBox "Page30 was clicked" so that it looks like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub DummyTextBox_GotFocus()
  2.  MsgBox "Page30 was clicked"
  3. End Sub
Now go back to Design View and click on Page30 to select it.

Goto View - Tab Order and move DummyTextBox so that it is the first control to receive focus on the page. Click OK.

Select the DummyTextBox control and shrink it as small as possible.

Run the form and click on Page30. The messagebox should popup with the message "Page30 was clicked" showing.

Now you can go back into the VBE and replace

MsgBox "Page30 was clicked"

with whatever code you want to run when the page is clicked.

Linq
Jul 27 '07 #2

100+
P: 553
Hey Linq

thanks very much. that method's great !!

i am realizing since have started learning VB that there are many weaknesses in this programming language such as this one - cant do onClick event when top of page is clicked..

Probably, C# or VC++ is the best...

The Click event of a tabbed page refers to the clicking on the actual page, what you would think of as the "background" of the page, not to the tab at the top that is used to switch from page to page. To accompish what you want to do, requires a little diddling!

In Design View Click on Page 30 and place a textbox on it; name it DummyTextBox.

Goto Properties - Events then click to the right of the On Got Focus event and select Code Builder. When the appropriate sub comes up place this code in it MsgBox "Page30 was clicked" so that it looks like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub DummyTextBox_GotFocus()
  2.  MsgBox "Page30 was clicked"
  3. End Sub
Now go back to Design View and click on Page30 to select it.

Goto View - Tab Order and move DummyTextBox so that it is the first control to receive focus on the page. Click OK.

Select the DummyTextBox control and shrink it as small as possible.

Run the form and click on Page30. The messagebox should popup with the message "Page30 was clicked" showing.

Now you can go back into the VBE and replace

MsgBox "Page30 was clicked"

with whatever code you want to run when the page is clicked.

Linq
Jul 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.