tuonela76
04-22-2009, 12:57 PM
I have 3 listboxes in a table in my document. One listbox is populated when the user hits the enter key after entering text. Another listbox is populated when a user makes a selection in one of several drop-down boxes. The other is populated when the user clicks a specific commandbutton after highlighting an item from each of the first two listboxes. My listboxes are fmMultiSelectSingle because my code uses the "Text" property of a selected item in the listbox to populate another listbox.
My problem is, when the user saves the document and closes it and then re-opens it later, highlighted values appear, but then after a few seconds they disappear. Other values in the listbox never appear unless they are listed above the highlighted value in the listbox (if they are listed above the highlighted value, they appear and then disappear).
I need all previously populated values to populate the listboxes when the user re-opens a document after having saved and closed the document.
Any suggestions? My code is below:
Public chkbxVal63 As Boolean
Private Sub Document_Open()
'Set a boolean value for the CheckBox63_Click event to use
If CheckBox63.Value Then
chkbxVal63 = True
Else
chkbxVal63 = False
End If
'Set the options in the drop-downs
ComboBox0.List = Array(" ", "N/A", "No", "Yes")
ComboBox1.List = Array(" ", "N/A", "No", "Yes")
ComboBox2.List = Array(" ", "N/A", "No", "Yes")
ComboBox3.List = Array(" ", "N/A", "No", "Yes")
ComboBox4.List = Array(" ", "N/A", "No", "Yes")
ComboBox5.List = Array(" ", "N/A", "No", "Yes")
ComboBox6.List = Array(" ", "N/A", "No", "Yes")
ComboBox7.List = Array(" ", "N/A", "No", "Yes")
ComboBox8.List = Array(" ", "N/A", "No", "Yes")
ComboBox10.List = Array(" ", "No", "Yes")
ComboBox11.List = Array(" ", "No", "Yes")
ComboBox12.List = Array(" ", "No", "Both", "Removals", "Adds")
ComboBox13.List = Array(" ", "No", "Yes")
ComboBox14.List = Array(" ", "No", "Both", "Downgrades", "Upgrades")
ComboBox15.List = Array(" ", "No", "Both", "Removals", "Adds")
ComboBox16.List = Array(" ", "No", "Yes")
ComboBox17.List = Array(" ", "No", "Both", "Downgrades", "Upgrades")
ComboBox18.List = Array(" ", "No", "Yes")
'Set the values of the drop-downs to blank
ComboBox0.Value = " "
ComboBox1.Value = " "
ComboBox2.Value = " "
ComboBox3.Value = " "
ComboBox4.Value = " "
ComboBox5.Value = " "
ComboBox6.Value = " "
ComboBox7.Value = " "
ComboBox10.Value = " "
ComboBox11.Value = " "
ComboBox12.Value = " "
ComboBox13.Value = " "
ComboBox14.Value = " "
ComboBox15.Value = " "
ComboBox16.Value = " "
ComboBox17.Value = " "
ComboBox18.Value = " "
ComboBox8.Value = " "
End Sub
Private Sub CheckBox63_Click()
'Check or uncheck the checkbox
CheckBox63.Value = (Not chkbxVal63)
chkbxVal63 = CheckBox63.Value
'If the box is checked, check the other two and disable them
If CheckBox63.Value Then
CheckBox61.Value = True
CheckBox62.Value = True
CheckBox61.Enabled = False
CheckBox62.Enabled = False
'Otherwise, uncheck other boxes and enable them
Else
CheckBox61.Value = False
CheckBox62.Value = False
CheckBox61.Enabled = True
CheckBox62.Enabled = True
End If
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
'If the user hits the enter key, populate the listbox as long as the text is not blank
'and the listbox does not already have ten values
If (KeyCode = 13) Then
If Not TextBox1.Value = "" Then
If ListBox1.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
ListBox1.AddItem TextBox1.Text
TextBox1.Text = ""
End If
Else
MsgBox "You must enter a product."
End If
End If
End Sub
Private Sub ComboBox0_Change()
ComboBox1.Select
End Sub
Private Sub ComboBox1_Change()
ComboBox2.Select
End Sub
Private Sub ComboBox2_Change()
ComboBox3.Select
End Sub
Private Sub ComboBox3_Change()
ComboBox4.Select
End Sub
Private Sub ComboBox4_Change()
ComboBox5.Select
End Sub
Private Sub ComboBox5_Change()
ComboBox6.Select
End Sub
Private Sub ComboBox6_Change()
ComboBox7.Select
End Sub
Private Sub ComboBox7_Change()
ComboBox8.Select
End Sub
Private Sub ComboBox8_Change()
ComboBox10.Select
End Sub
Private Sub ComboBox10_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox10.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Outside Moves"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox11.Select
End Sub
Private Sub ComboBox11_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox11.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "New Installs"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox12.Select
End Sub
Private Sub ComboBox12_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox12.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Removals/Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox12.Value = "Removals" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Removals"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox12.Value = "Adds" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox13.Select
End Sub
Private Sub ComboBox13_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox13.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Changes"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox14.Select
End Sub
Private Sub ComboBox14_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox14.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Downgrades/Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox14.Value = "Downgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Downgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox14.Value = "Upgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox15.Select
End Sub
Private Sub ComboBox15_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox15.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Removals/Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox15.Value = "Removals" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Removals"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox15.Value = "Adds" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox16.Select
End Sub
Private Sub ComboBox16_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox16.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Changes"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox17.Select
End Sub
Private Sub ComboBox17_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox17.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Downgrades/Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox17.Value = "Downgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Downgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox17.Value = "Upgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox18.Select
End Sub
Private Sub ComboBox18_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox18.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "PD Orders"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
TextBox1.Select
End Sub
Private Sub cmdBtn1_Click()
'Remove the selected item and highlight the last item in the listbox, or display a message
If ListBox1.ListIndex < 0 Then
MsgBox "Nothing to remove."
TextBox1.Select
Else
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.ListIndex = ListBox1.ListCount - 1
End If
End Sub
Private Sub cmdBtn2_Click()
'Remove the selected item and highlight the last item in the listbox, or display a message
If ListBox2.ListIndex < 0 Then
MsgBox "Nothing to remove."
ComboBox10.Select
Else
ListBox2.RemoveItem ListBox2.ListIndex
ListBox2.ListIndex = ListBox2.ListCount - 1
End If
End Sub
Private Sub cmdBtn3_Click()
Dim str As String
'Add the selection from listbox1 and listbox2 as a concatenated string
'Display messages if one or both listboxes contain no highlighted(selected) item.
str = ListBox1.Text & " - " & ListBox2.Text
If ListBox3.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
If ListBox1.ListIndex < 0 Then
If ListBox2.ListIndex < 0 Then
MsgBox "There is nothing to add."
ComboBox10.Select
Else
MsgBox "Please enter products."
TextBox1.Select
End If
Else
If ListBox2.ListIndex < 0 Then
MsgBox "Please make a selection for Scope."
ComboBox10.Select
Else
ListBox3.AddItem str
ListBox3.Selected(0) = True
End If
End If
End If
'If the last item from both boxes is highlighted, do not select anything
If ListBox1.Selected(ListBox1.ListCount - 1) Then
If ListBox2.Selected(ListBox2.ListCount - 1) Then
ListBox1.Selected(ListBox1.ListCount - 1) = False
ListBox2.Selected(ListBox2.ListCount - 1) = False
End If
Else
ListBox1.Selected(0) = True
ListBox2.Selected(0) = True
End If
End Sub
Private Sub cmdBtn4_Click()
'Remove the selected item and highlight the last item in the listbox, or display a message
If ListBox3.ListIndex < 0 Then
MsgBox "Nothing to remove."
cmdBtn3.Select
Else
ListBox3.RemoveItem ListBox3.ListIndex
ListBox3.ListIndex = ListBox3.ListCount - 1
End If
End Sub
My problem is, when the user saves the document and closes it and then re-opens it later, highlighted values appear, but then after a few seconds they disappear. Other values in the listbox never appear unless they are listed above the highlighted value in the listbox (if they are listed above the highlighted value, they appear and then disappear).
I need all previously populated values to populate the listboxes when the user re-opens a document after having saved and closed the document.
Any suggestions? My code is below:
Public chkbxVal63 As Boolean
Private Sub Document_Open()
'Set a boolean value for the CheckBox63_Click event to use
If CheckBox63.Value Then
chkbxVal63 = True
Else
chkbxVal63 = False
End If
'Set the options in the drop-downs
ComboBox0.List = Array(" ", "N/A", "No", "Yes")
ComboBox1.List = Array(" ", "N/A", "No", "Yes")
ComboBox2.List = Array(" ", "N/A", "No", "Yes")
ComboBox3.List = Array(" ", "N/A", "No", "Yes")
ComboBox4.List = Array(" ", "N/A", "No", "Yes")
ComboBox5.List = Array(" ", "N/A", "No", "Yes")
ComboBox6.List = Array(" ", "N/A", "No", "Yes")
ComboBox7.List = Array(" ", "N/A", "No", "Yes")
ComboBox8.List = Array(" ", "N/A", "No", "Yes")
ComboBox10.List = Array(" ", "No", "Yes")
ComboBox11.List = Array(" ", "No", "Yes")
ComboBox12.List = Array(" ", "No", "Both", "Removals", "Adds")
ComboBox13.List = Array(" ", "No", "Yes")
ComboBox14.List = Array(" ", "No", "Both", "Downgrades", "Upgrades")
ComboBox15.List = Array(" ", "No", "Both", "Removals", "Adds")
ComboBox16.List = Array(" ", "No", "Yes")
ComboBox17.List = Array(" ", "No", "Both", "Downgrades", "Upgrades")
ComboBox18.List = Array(" ", "No", "Yes")
'Set the values of the drop-downs to blank
ComboBox0.Value = " "
ComboBox1.Value = " "
ComboBox2.Value = " "
ComboBox3.Value = " "
ComboBox4.Value = " "
ComboBox5.Value = " "
ComboBox6.Value = " "
ComboBox7.Value = " "
ComboBox10.Value = " "
ComboBox11.Value = " "
ComboBox12.Value = " "
ComboBox13.Value = " "
ComboBox14.Value = " "
ComboBox15.Value = " "
ComboBox16.Value = " "
ComboBox17.Value = " "
ComboBox18.Value = " "
ComboBox8.Value = " "
End Sub
Private Sub CheckBox63_Click()
'Check or uncheck the checkbox
CheckBox63.Value = (Not chkbxVal63)
chkbxVal63 = CheckBox63.Value
'If the box is checked, check the other two and disable them
If CheckBox63.Value Then
CheckBox61.Value = True
CheckBox62.Value = True
CheckBox61.Enabled = False
CheckBox62.Enabled = False
'Otherwise, uncheck other boxes and enable them
Else
CheckBox61.Value = False
CheckBox62.Value = False
CheckBox61.Enabled = True
CheckBox62.Enabled = True
End If
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
'If the user hits the enter key, populate the listbox as long as the text is not blank
'and the listbox does not already have ten values
If (KeyCode = 13) Then
If Not TextBox1.Value = "" Then
If ListBox1.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
ListBox1.AddItem TextBox1.Text
TextBox1.Text = ""
End If
Else
MsgBox "You must enter a product."
End If
End If
End Sub
Private Sub ComboBox0_Change()
ComboBox1.Select
End Sub
Private Sub ComboBox1_Change()
ComboBox2.Select
End Sub
Private Sub ComboBox2_Change()
ComboBox3.Select
End Sub
Private Sub ComboBox3_Change()
ComboBox4.Select
End Sub
Private Sub ComboBox4_Change()
ComboBox5.Select
End Sub
Private Sub ComboBox5_Change()
ComboBox6.Select
End Sub
Private Sub ComboBox6_Change()
ComboBox7.Select
End Sub
Private Sub ComboBox7_Change()
ComboBox8.Select
End Sub
Private Sub ComboBox8_Change()
ComboBox10.Select
End Sub
Private Sub ComboBox10_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox10.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Outside Moves"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox11.Select
End Sub
Private Sub ComboBox11_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox11.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "New Installs"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox12.Select
End Sub
Private Sub ComboBox12_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox12.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Removals/Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox12.Value = "Removals" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Removals"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox12.Value = "Adds" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox13.Select
End Sub
Private Sub ComboBox13_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox13.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Changes"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox14.Select
End Sub
Private Sub ComboBox14_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox14.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Downgrades/Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox14.Value = "Downgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Downgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox14.Value = "Upgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver Yes: Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox15.Select
End Sub
Private Sub ComboBox15_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox15.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Removals/Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox15.Value = "Removals" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Removals"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox15.Value = "Adds" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Adds"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox16.Select
End Sub
Private Sub ComboBox16_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox16.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Changes"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox17.Select
End Sub
Private Sub ComboBox17_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox17.Value = "Both" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Downgrades/Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox17.Value = "Downgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Downgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
If ComboBox17.Value = "Upgrades" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "Driver No: Upgrades"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
ComboBox18.Select
End Sub
Private Sub ComboBox18_Change()
Dim str As String
'If the user selects a particular option, populate the listbox with a particular string
'unless the listbox already has 10 values
If ComboBox18.Value = "Yes" Then
If ListBox2.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
str = "PD Orders"
ListBox2.AddItem str
ListBox2.Selected(0) = True
End If
End If
TextBox1.Select
End Sub
Private Sub cmdBtn1_Click()
'Remove the selected item and highlight the last item in the listbox, or display a message
If ListBox1.ListIndex < 0 Then
MsgBox "Nothing to remove."
TextBox1.Select
Else
ListBox1.RemoveItem ListBox1.ListIndex
ListBox1.ListIndex = ListBox1.ListCount - 1
End If
End Sub
Private Sub cmdBtn2_Click()
'Remove the selected item and highlight the last item in the listbox, or display a message
If ListBox2.ListIndex < 0 Then
MsgBox "Nothing to remove."
ComboBox10.Select
Else
ListBox2.RemoveItem ListBox2.ListIndex
ListBox2.ListIndex = ListBox2.ListCount - 1
End If
End Sub
Private Sub cmdBtn3_Click()
Dim str As String
'Add the selection from listbox1 and listbox2 as a concatenated string
'Display messages if one or both listboxes contain no highlighted(selected) item.
str = ListBox1.Text & " - " & ListBox2.Text
If ListBox3.ListCount = 10 Then
MsgBox "Only 10 Items are allowed in the list."
Else
If ListBox1.ListIndex < 0 Then
If ListBox2.ListIndex < 0 Then
MsgBox "There is nothing to add."
ComboBox10.Select
Else
MsgBox "Please enter products."
TextBox1.Select
End If
Else
If ListBox2.ListIndex < 0 Then
MsgBox "Please make a selection for Scope."
ComboBox10.Select
Else
ListBox3.AddItem str
ListBox3.Selected(0) = True
End If
End If
End If
'If the last item from both boxes is highlighted, do not select anything
If ListBox1.Selected(ListBox1.ListCount - 1) Then
If ListBox2.Selected(ListBox2.ListCount - 1) Then
ListBox1.Selected(ListBox1.ListCount - 1) = False
ListBox2.Selected(ListBox2.ListCount - 1) = False
End If
Else
ListBox1.Selected(0) = True
ListBox2.Selected(0) = True
End If
End Sub
Private Sub cmdBtn4_Click()
'Remove the selected item and highlight the last item in the listbox, or display a message
If ListBox3.ListIndex < 0 Then
MsgBox "Nothing to remove."
cmdBtn3.Select
Else
ListBox3.RemoveItem ListBox3.ListIndex
ListBox3.ListIndex = ListBox3.ListCount - 1
End If
End Sub