View Single Post
 
Old 09-16-2018, 03:22 PM
jrooney7 jrooney7 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Sep 2018
Posts: 23
jrooney7 is on a distinguished road
Default Adjust userform layout based on combobox selection

Hello all,

I have a userform with multiple textboxes and comboboxes. I have set some to be hidden when the userform is run, and then want them to become visible if certain selections are made in the userform comboboxes. The example below is from the same userform in Excel, and it works there, but it is not working in Word. Any thoughts?

Code:
Private Sub SafetiesComboBox_Change()
    Select Case SafetiesComboBox.Value
    
    Case "Other/Multiple"
        FirearmPreFireUserForm.SafetiesTextBox.Visible = True
        SafetiesTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height
        SingleActionTP.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 6.5
        SAL.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 6.5
        SingleActionLowTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 4.5
        SAH.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 6.5
        SingleActionHighTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 4.5
        DoubleActionTP.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 24.5
        DAL.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 24.5
        DoubleActionLowTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 22.5
        DAH.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 24.5
        DoubleActionHighTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 22.5
        HybridActionTP.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 43.5
        HAL.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 43.5
        HybridActionLowTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 40.5
        HAH.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 43.5
        HybridActionHighTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 40.5
        Tests.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 4.5
        TestAmmo.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 4.5
        TestsComboBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 16.5
        TestAmmoTextBox.Top = SafetiesTextBox.Top + SafetiesTextBox.Height + 16.5
        Notes.Top = TestsComboBox.Top + TestsComboBox.Height + 12
        NotesTextBox.Top = TestsComboBox.Top + TestsComboBox.Height + 10
        Results.Top = NotesTextBox.Top + NotesTextBox.Height + 6.5
        ResultsTextBox.Top = NotesTextBox.Top + NotesTextBox.Height + 4.5
        FirearmCommandButton1.Top = ResultsTextBox.Top + ResultsTextBox.Height + 22.5
        FirearmCommandButton2.Top = ResultsTextBox.Top + ResultsTextBox.Height + 22.5
        FirearmPreFireUserForm.ScrollHeight = FirearmCommandButton1.Top + FirearmCommandButton1.Height + 28
                
    Case Else
        FirearmPreFireUserForm.SafetiesTextBox.Visible = False
        SingleActionTP.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 6.5
        SAL.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 6.5
        SingleActionLowTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 4.5
        SAH.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 6.5
        SingleActionHighTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 4.5
        DoubleActionTP.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 24.5
        DAL.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 24.5
        DoubleActionLowTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 22.5
        DAH.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 24.5
        DoubleActionHighTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 22.5
        HybridActionTP.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 43.5
        HAL.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 43.5
        HybridActionLowTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 40.5
        HAH.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 43.5
        HybridActionHighTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 40.5
        Tests.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 4.5
        TestAmmo.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 4.5
        TestsComboBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 16.5
        TestAmmoTextBox.Top = SafetiesComboBox.Top + SafetiesComboBox.Height + 16.5
        Notes.Top = TestsComboBox.Top + TestsComboBox.Height + 12
        NotesTextBox.Top = TestsComboBox.Top + TestsComboBox.Height + 10
        Results.Top = NotesTextBox.Top + NotesTextBox.Height + 6.5
        ResultsTextBox.Top = NotesTextBox.Top + NotesTextBox.Height + 4.5
        FirearmCommandButton1.Top = ResultsTextBox.Top + ResultsTextBox.Height + 22.5
        FirearmCommandButton2.Top = ResultsTextBox.Top + ResultsTextBox.Height + 22.5
        FirearmPreFireUserForm.ScrollHeight = FirearmCommandButton1.Top + FirearmCommandButton1.Height + 28
        
End Select

End Sub
Reply With Quote