Can't switch tab back in Multipage userform

th284

New Member
Joined
Jul 25, 2011
Messages
4
Hi, I have two pages in the userform. What I was trying to do is that certain textbox (txtDate) needs to be entered on the page1 before going to page2. The user can still select page2 however I want the vba to bring the page back to page1 if the data is missing.

Here is the code:

Private Sub MultiPage1_Change()
If MultiPage1.Value = 1 And txtDate = "" Then
MultiPage1.Value = 0
txtDate .BackColor = &H40C0
End If

It didn't work completely - the tab selection on top was on page1 however all the controls shown are still the controls under page2. I have to manulally click page1.

I also tried MultiPage1.Page(0).Enabled=True but it didn't work either.

Please help. Thank you.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try placing the code in the MultiPage1_KeyUp and MultiPage1_MouseUp events instead of the Change event.
 
Upvote 0
It actually didn't do anything for me (I don't think the subs were executed). I tried the KeyDown and MouseDown and it didn't work either.

What I like to happen is when this textbox is empty VBA will prevent the user go to the next page until it is entered. Maybe there's a different way to do it, for example: disable the next page?
 
Upvote 0
It actually didn't do anything for me (I don't think the subs were executed). I tried the KeyDown and MouseDown and it didn't work either.

What I like to happen is when this textbox is empty VBA will prevent the user go to the next page until it is entered. Maybe there's a different way to do it, for example: disable the next page?

Can you try using the textbox Exit event ?
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top