if all items in listbox are the same

D

deb

access 2003

On form f018ContrPerf is have a listbox called lstUnitType(multiselect=none).

How can I determine if all items in listbox are the same? ie all ST or all
IT...

If they are the same then
Me.f018ContrPerfDetails.Form.optHP.Visible = True
Me.f018ContrPerfDetails.Form.FrameElem_Label.Visible = True
 
J

John W. Vinson

access 2003

On form f018ContrPerf is have a listbox called lstUnitType(multiselect=none).

How can I determine if all items in listbox are the same? ie all ST or all
IT...

If they are the same then
Me.f018ContrPerfDetails.Form.optHP.Visible = True
Me.f018ContrPerfDetails.Form.FrameElem_Label.Visible = True

What's the listbox's RowSource? Where does it get its data FROM?

And why on Earth would you have a listbox to select from multiple identical
values???
 
D

deb

User can either select a specific unit or can sellect All Units from the
UnitNo combobox.

If the user selects all units then I need to know if all the units are alike.
because if they are all ST then I will need to display an ST form. If some
are ST and one is a IT the I must display a different form.

Thank you for your help!

Private Sub UnitNo_AfterUpdate()


If IsNull(Me.UnitNo) Then 'make subform visible
Me.f018ContrPerfEmissGuaDetails.Form.Visible = False
Else
Me.f018ContrPerfEmissGuaDetails.Form.Visible = True
End If


Select Case Me!UnitNo.Value ' rowsource for lstUnitType
Dim strsql2 As String

Case 0 ' All units
strsql2 = "SELECT DISTINCT t000GFacts.UnitType, t040Project.ProjectID,
t040Project.ProjectName, " & _
" t041ProjectDetails.UnitID, t000GFacts.Unit " & _
" FROM t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails " & _
" ON t000GFacts.UnitID = t041ProjectDetails.UnitID) " & _
" ON t040Project.ProjectID = t041ProjectDetails.ProjectID " & _
" WHERE (((t040Project.ProjectID)=[Forms]![f001ProjectReview]![ProjectID]))
" & _
" ORDER BY t000GFacts.Unit;"
Me.lstUnitType.RowSource = strsql2
Me.lstUnitType.Requery

Case Else 'selected unit
strsql2 = "SELECT DISTINCT t000GFacts.UnitType, t040Project.ProjectID,
t040Project.ProjectName, " & _
" t041ProjectDetails.UnitID, t000GFacts.Unit " & _
" FROM t040Project INNER JOIN (t000GFacts INNER JOIN t041ProjectDetails " & _
" ON t000GFacts.UnitID = t041ProjectDetails.UnitID) " & _
" ON t040Project.ProjectID = t041ProjectDetails.ProjectID " & _
" WHERE
(((t041ProjectDetails.UnitID)=[Forms]![f001ProjectReview]![f018ContrPerfEmissGua].[Form]![UnitNo])) " & _
" ORDER BY t000GFacts.Unit;"
Me.lstUnitType.RowSource = strsql2
Me.lstUnitType.Requery


' edit code Display Frame Element ( HP IP LP)
If (Me.lstUnitType.Value) = "ST" Then

Me.f018ContrPerfEmissGuaDetails.Form.optHPorIPorLP.Visible = True
Me.f018ContrPerfEmissGuaDetails.Form.FrameElem_Label.Visible = True
Else
Me.f018ContrPerfEmissGuaDetails.Form.optHPorIPorLP.Visible = False
Me.f018ContrPerfEmissGuaDetails.Form.FrameElem_Label.Visible = False
MsgBox " else"

End If
End Select
 
J

John W. Vinson

User can either select a specific unit or can sellect All Units from the
UnitNo combobox.

If the user selects all units then I need to know if all the units are alike.
because if they are all ST then I will need to display an ST form. If some
are ST and one is a IT the I must display a different form.

Remember... nobody here knows anything about your business or your database
unless you post it. What does it mean for units to be "alike"? Is ST a field,
a portion of a field, the primary key of the listbox's record, a different
field in the listboxes' record? I.e. what steps must Access take to determine
"if they are all ST"?
 
D

deb

sorry it took so long to answer, I was in class all week.

The listbox is unbound and the primary key of the listbox's record is
UnitType (text) some of the options in the list box 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 display the ST form.
 
J

John W. Vinson

sorry it took so long to answer, I was in class all week.

The listbox is unbound and the primary key of the listbox's record is
UnitType (text) some of the options in the list box 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 display the ST form.

What is the listbox's RowSource? What's the point of a listbox which displays
multiple identical records? I don't understand the purpose of this form
control at all!

You can do a Query against a table (or another query) but you can't do a Query
on a listbox. I think you need to take a step back and look at the data
underlying the listbox, not at the listbox itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top