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.
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,117
Office Version
  1. 2016
Platform
  1. Windows
Try placing the code in the MultiPage1_KeyUp and MultiPage1_MouseUp events instead of the Change event.
 

th284

New Member
Joined
Jul 25, 2011
Messages
4
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?
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,117
Office Version
  1. 2016
Platform
  1. Windows
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 ?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,842
Messages
5,598,396
Members
414,235
Latest member
sucosama

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
Top