"deb" <(E-Mail Removed)> wrote in message
news:54864F9F-3BDA-4D5C-B654-(E-Mail Removed)...
> Listbox has 5 fields and the first one is the one to use for comparison.
> it is named UnitType. (text value)
The names of the fields in a list box's rowsource are irrelevant -- when
you're working with the list box, all you have are rows, columns, and
ItemData.
I assume that the bound column is some other column; otherwise, Access
would not be able to distinguish among the rows in the list box.
This code should tell you if all rows in the list box have the same value
for the first column:
'------ start of code ------
' WARNING: AIR CODE
Dim i As Long
Dim blnSameType As Boolean
Dim strUnitType As String
blnSameType = True
With lstUnitType
i = Abs(.ColumnHeads)
If .ListCount > i Then
strUnitType = .Column(0, i)
While i < (.ListCount - 1) And blnSameType
i = i + 1
If .Column(0, i) & "" <> strUnitType Then
blnSameType = False
End If
Wend
End If
End With
Me.f018ContrPerfDetails.Form.optHP.Visible = blnSameType
'------ end of code ------
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)