Greetings,
I am trying put together an userform that will open a PDF file from a folder location dependent on 2 comboboxes. The first combobox gives the user a choice of 3 types, and then the second combobox will provide the user the choice of files to open. I want the user to be able to choose that file in the second combobox and then hit open an file button to open the PDF file from the known file location.
This is my code my code so far:
Private Sub cboType_Change()
'Populates the second combobox
Dim index As Integer
index = cboType.ListIndex
cboChassisSpec.Clear
Select Case index
Case Is = 0 'If car type altered is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 10.2 Altered"
.AddItem "SFI Spec 10.3 Altered"
End With
Case Is = 1 'If car type door cars is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 25.1H Full Bodied Car"
.AddItem "SFI Spec 25.2C Full Bodied Car"
End With
Case Is = 2 'If car type dragster is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 2.5C RED"
.AddItem "SFI Spec 2.7C RED"
End With
End Select
End Sub
Private Sub cmdClose_Click()
Unload Me 'Close the userform
End Sub
Private Sub UserForm_Initialize()
'Populate first combobox with initial car categories
cboType.AddItem "Altereds" 'first car type
cboType.AddItem "Door Cars" 'second car type
cboType.AddItem "Dragsters" 'third car type
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Using Query Close event of Userform
'Comparing the constant value of CloseMode variable
'If it is equal to inbuilt constant of control menu
'Then prevent closing of userform and
'Display information message dialog box
If CloseMode = vbFormControlMenu Then
'Changing Cancel variable value to True
'By default, it is False
Cancel = True
MsgBox "You can't close the dialog like this!"
End If
End Sub
I am trying put together an userform that will open a PDF file from a folder location dependent on 2 comboboxes. The first combobox gives the user a choice of 3 types, and then the second combobox will provide the user the choice of files to open. I want the user to be able to choose that file in the second combobox and then hit open an file button to open the PDF file from the known file location.
This is my code my code so far:
Private Sub cboType_Change()
'Populates the second combobox
Dim index As Integer
index = cboType.ListIndex
cboChassisSpec.Clear
Select Case index
Case Is = 0 'If car type altered is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 10.2 Altered"
.AddItem "SFI Spec 10.3 Altered"
End With
Case Is = 1 'If car type door cars is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 25.1H Full Bodied Car"
.AddItem "SFI Spec 25.2C Full Bodied Car"
End With
Case Is = 2 'If car type dragster is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 2.5C RED"
.AddItem "SFI Spec 2.7C RED"
End With
End Select
End Sub
Private Sub cmdClose_Click()
Unload Me 'Close the userform
End Sub
Private Sub UserForm_Initialize()
'Populate first combobox with initial car categories
cboType.AddItem "Altereds" 'first car type
cboType.AddItem "Door Cars" 'second car type
cboType.AddItem "Dragsters" 'third car type
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Using Query Close event of Userform
'Comparing the constant value of CloseMode variable
'If it is equal to inbuilt constant of control menu
'Then prevent closing of userform and
'Display information message dialog box
If CloseMode = vbFormControlMenu Then
'Changing Cancel variable value to True
'By default, it is False
Cancel = True
MsgBox "You can't close the dialog like this!"
End If
End Sub