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