If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
compare fields in listbox
access 2003
On form f018ContrPerf I have a combobox called "UnitNo" and a listbox called "lstUnitType" (multiselect=none), unbound and the primary key of the listbox's record is UnitType (text) . User selects a specific unit or can select "All Units" from the "UnitNo" combobox. When the selection is made the listbox "lstUnitType" is populated with the specific UnitType or a list of all UnitTypes if the selection was "All Units". If "all units" selected then I need to know if all the UnitTypes in the listbox "lstUnitType" fieldname "UnitType" are alike. If they are alike then Me.f018ContrPerfDetails.Form.optHP.Visible = True else Me.f018ContrPerfDetails.Form.optHP.Visible = false Some of the options in the listbox "lstUnitType" may be something like... ST ST ST or it could be ST BFTG and so on so if the list box displays: ST ST ST Then Me.f018ContrPerfDetails.Form.optHP.Visible = True else Me.f018ContrPerfDetails.Form.optHP.Visible = false -- deb |
#2
|
|||
|
|||
compare fields in listbox
"deb" wrote in message
... access 2003 On form f018ContrPerf I have a combobox called "UnitNo" and a listbox called "lstUnitType" (multiselect=none), unbound and the primary key of the listbox's record is UnitType (text) . User selects a specific unit or can select "All Units" from the "UnitNo" combobox. When the selection is made the listbox "lstUnitType" is populated with the specific UnitType or a list of all UnitTypes if the selection was "All Units". If "all units" selected then I need to know if all the UnitTypes in the listbox "lstUnitType" fieldname "UnitType" are alike. If they are alike then Me.f018ContrPerfDetails.Form.optHP.Visible = True else Me.f018ContrPerfDetails.Form.optHP.Visible = false Some of the options in the listbox "lstUnitType" may be something like... ST ST ST or it could be ST BFTG and so on so if the list box displays: ST ST ST Then Me.f018ContrPerfDetails.Form.optHP.Visible = True else Me.f018ContrPerfDetails.Form.optHP.Visible = false How many columns does the list box have? Of those, which column contains the field that you want to compare for "likeness"? -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#3
|
|||
|
|||
compare fields in listbox
Listbox has 5 fields and the first one is the one to use for comparison.
it is named UnitType. (text value) Thank you!!! -- deb "Dirk Goldgar" wrote: "deb" wrote in message ... access 2003 On form f018ContrPerf I have a combobox called "UnitNo" and a listbox called "lstUnitType" (multiselect=none), unbound and the primary key of the listbox's record is UnitType (text) . User selects a specific unit or can select "All Units" from the "UnitNo" combobox. When the selection is made the listbox "lstUnitType" is populated with the specific UnitType or a list of all UnitTypes if the selection was "All Units". If "all units" selected then I need to know if all the UnitTypes in the listbox "lstUnitType" fieldname "UnitType" are alike. If they are alike then Me.f018ContrPerfDetails.Form.optHP.Visible = True else Me.f018ContrPerfDetails.Form.optHP.Visible = false Some of the options in the listbox "lstUnitType" may be something like... ST ST ST or it could be ST BFTG and so on so if the list box displays: ST ST ST Then Me.f018ContrPerfDetails.Form.optHP.Visible = True else Me.f018ContrPerfDetails.Form.optHP.Visible = false How many columns does the list box have? Of those, which column contains the field that you want to compare for "likeness"? -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#4
|
|||
|
|||
compare fields in listbox
"deb" wrote in message
... 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) |
Thread Tools | |
Display Modes | |
|
|