Disable TabStrip tabs when code is running

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,047
Office Version
  1. 2016
Platform
  1. Windows
In the past I have used this to disable multipage pages while a code is running. This only leave the active PAGE active and disables all the other pages until the process is finished, This prevents the user from navigating to other pages on a Multipage. I have now replaced the Multipage with a tab strip and was trying to do the same. However I can not get it to work.
VBA Code:
Private Sub CommandButton1_Click()
InActivePagesEnabled(MultiPage1) = False ' disable tabs on multipage1
         Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
InActivePagesEnabled(MultiPage1) = True 'enable tabs on multipage1
End Sub

I keep getting an Run type Error 13 Type Mismatch on the first line of code. I tried this
VBA Code:
Private Sub CommandButton1_Click()
InActivePagesEnabled(TabStrip1) = False ' disable tabs on multipage1
         Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
InActivePagesEnabled(TabStrip1) = True 'enable tabs on multipage1
End Sub

And
VBA Code:
Private Sub CommandButton1_Click()
InActivePagesEnabled(UserForm1.TabStrip1) = False ' disable tabs on multipage1
         Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
InActivePagesEnabled(UserForm1.TabStrip1) = True 'enable tabs on multipage1
End Sub
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,263
Office Version
  1. 365
Platform
  1. Windows
Instead of disabling why not use a boolean to prevent the code running?
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,047
Office Version
  1. 2016
Platform
  1. Windows
Norie

I'm not sure what you mean. I need the code to run in the module. however I would like to prevent the user from being able to change tabs. The multi page code was a very easy way to disable and enable the pages while the code was running. I was look for a similar simple fix.
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,047
Office Version
  1. 2016
Platform
  1. Windows
Its ok I have done it with this
VBA Code:
''Disable Tabs of Tab strip, only leave active tab TRUE
  Dim oTab As MSForms.Tab
    For Each oTab In UserForm1.TabStrip1.Tabs
        If oTab.Index <> UserForm1.TabStrip1.Value Then
            oTab.Enabled = False
        End If
    Next oTab
          Application.Run "StaffDetails.UpdateRecords" ' runs this code from module 
 ''Enable All Tabs of Tab strip, 
    For Each oTab In UserForm1.TabStrip1.Tabs
        If oTab.Index <> UserForm1.TabStrip1.Value Then
            oTab.Enabled = True
        End If
    Next oTab
 
Solution

smozgur

BatCoder
Joined
Feb 28, 2002
Messages
1,343
It looks you already have a solution. However, the Enabled property of the TabStrip control might also help.

VBA Code:
UserForm1.TabStrip1.Enabled = False
Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
UserForm1.TabStrip1.Enabled = True
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,047
Office Version
  1. 2016
Platform
  1. Windows
Smozgur

Thanks for your contribution, Just as good as what I did. Only difference is it disables all the tabs on the strip, where as my code, showed the selected tab as active "True" and "False" disabled for all the other tabs.

Either one is as good

Thanks,
 

Watch MrExcel Video

Forum statistics

Threads
1,127,107
Messages
5,622,780
Members
415,927
Latest member
vedasinternational

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