A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

compare fields in listbox



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2010, 05:29 PM posted to microsoft.public.access.forms
deb
external usenet poster
 
Posts: 898
Default 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  
Old May 4th, 2010, 05:48 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default 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  
Old May 4th, 2010, 06:06 PM posted to microsoft.public.access.forms
deb
external usenet poster
 
Posts: 898
Default 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  
Old May 4th, 2010, 06:28 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.