Hi Guys
I have a combobox with 10 departments. On the form there are 10 labels as well.My requirement is when I select a dept name from the combobox then it should display that on label1 and for the rest of the labels, all other departments should be displayed.
Now suppose I select another department from the combobox then again on label1 the current selected department name should be displayed and the rest of the labels would display the other 9 departments.
Can anyone please help me with the vba code for this please.I have written the following code in excel/vba but combobox list property is not working in access/vba.
Regards
AMan
I have a combobox with 10 departments. On the form there are 10 labels as well.My requirement is when I select a dept name from the combobox then it should display that on label1 and for the rest of the labels, all other departments should be displayed.
Now suppose I select another department from the combobox then again on label1 the current selected department name should be displayed and the rest of the labels would display the other 9 departments.
Can anyone please help me with the vba code for this please.I have written the following code in excel/vba but combobox list property is not working in access/vba.
Code:
Private Sub Combo8_LostFocus()
Dim lngIndex As Long
Dim lngControlIndex As Long
lngControlIndex = 18
For lngIndex = 0 To Combo8.ListCount - 1
If lngIndex = Combo8.ListIndex Then
Me.Controls("Label18").Caption = Combo8.List(lngIndex)
Else
lngControlIndex = lngControlIndex + 1
Me.Controls("Label" & lngControlIndex).Caption = Combo8.List(lngIndex)
End If
Next
End Sub
Regards
AMan