PC Review


Reply
Thread Tools Rate Thread

compare fields in listbox

 
 
deb
Guest
Posts: n/a
 
      4th May 2010
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
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      4th May 2010
"deb" <(E-Mail Removed)> wrote in message
news:84B8DE24-0ABB-4F8D-B3A1-(E-Mail Removed)...
> 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)

 
Reply With Quote
 
deb
Guest
Posts: n/a
 
      4th May 2010
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" <(E-Mail Removed)> wrote in message
> news:84B8DE24-0ABB-4F8D-B3A1-(E-Mail Removed)...
> > 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)
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      4th May 2010
"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)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: compare values between combobox and listbox Stuart McCall Microsoft Access Form Coding 3 18th Feb 2010 09:49 PM
Compare multiple listbox contents TASDEVIL Microsoft Excel Programming 1 10th Oct 2005 01:19 AM
Compare Cells on Sheet to ListBox Selection =?Utf-8?B?Tk5leGNlbA==?= Microsoft Excel Programming 1 5th Oct 2004 06:46 PM
How to compare the value of items in ListBox? honeybee Microsoft C# .NET 1 23rd May 2004 12:39 PM
Compare 2 fields and then ouput 1 of 2 fields Steve Microsoft Access Queries 2 22nd Nov 2003 03:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:36 PM.