I am so close but yet soooo far...
I have a form with combo boxes which display the choices from the boxs in a list box.
If you choose from one of the 7 combo boxes it limits the display in the list box, if you choose another combo box, the listbox display is limited ever further...
It works great, buttttt
I need 4 of the combo boxes to be MULTIselect list boxes.
The boxes that are needed to be the combo boxes are (cboFY, cboCC, cboSigmaStatus and cboProjectType.
The code is as follows:
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT FY, CC, ChargeNo, SigmaPlusNo, ProjectType, SigmaStatus, BeltName " & _
"FROM qProjectt WHERE FY like '"
Private Const strSQL2 = "' AND CC like '"
Private Const strSQL3 = "' AND BeltName like '"
Private Const strSQL4 = "' AND ChargeNo like '"
Private Const strSQL5 = "' AND ProjectType like '"
Private Const strSQL6 = "' AND SigmaPlusNo like '"
Private Const strSQL7 = "' AND SigmaStatus like '"
Private Const strSQL8 = "' Order by FY desc;"
Private strSQL As String
Private Const strMsg1 = "Select a product from the list"
Private Const strMsg2 = "Select a FY from the list"
Private Sub cboBeltName_AfterUpdate()
If Me!cboBeltName.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboChargeNo_AfterUpdate()
If Me!cboChargeNo.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboFY_AfterUpdate()
If Me!cboCC.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg1
End If
End Sub
Private Sub cboCC_AfterUpdate()
If Me!cboFY.Value <> "" Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Private Sub cboProjectType_AfterUpdate()
If Me!cboProjectType.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboSigmaPlusNo_AfterUpdate()
If Me!cboSigmaPlusNo.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboSigmaStatus_AfterUpdate()
If Me!cboSigmaStatus.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub Form_Activate()
If Me!cboFY.Value <> "" And Me!cboCC.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Private Sub FillList()
strSQL = strSQL1 & Me!cboFY.Value & _
strSQL2 & Me!cboCC.Value & _
strSQL3 & Me!cboBeltName.Value & _
strSQL4 & Me!cboChargeNo.Value & _
strSQL5 & Me!cboProjectType.Value & _
strSQL6 & Me!cboSigmaPlusNo.Value & _
strSQL7 & Me!cboSigmaStatus.Value & _
strSQL8
Me!lstOrders.RowSource = strSQL
Me!lstOrders.Requery
Me!lblList.Caption = "Orders from " & _
Me!cboFY.Value & " for " & _
Me!cboCC.Column(1)
If Me!lstOrders.ListCount = 0 Then
Me!lblList.Caption = "No " & Me!lblList.Caption
End If
End Sub
I can send the mdb if needed.
Thanks in advance. This forum is a lifesaver.
I have a form with combo boxes which display the choices from the boxs in a list box.
If you choose from one of the 7 combo boxes it limits the display in the list box, if you choose another combo box, the listbox display is limited ever further...
It works great, buttttt
I need 4 of the combo boxes to be MULTIselect list boxes.
The boxes that are needed to be the combo boxes are (cboFY, cboCC, cboSigmaStatus and cboProjectType.
The code is as follows:
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT FY, CC, ChargeNo, SigmaPlusNo, ProjectType, SigmaStatus, BeltName " & _
"FROM qProjectt WHERE FY like '"
Private Const strSQL2 = "' AND CC like '"
Private Const strSQL3 = "' AND BeltName like '"
Private Const strSQL4 = "' AND ChargeNo like '"
Private Const strSQL5 = "' AND ProjectType like '"
Private Const strSQL6 = "' AND SigmaPlusNo like '"
Private Const strSQL7 = "' AND SigmaStatus like '"
Private Const strSQL8 = "' Order by FY desc;"
Private strSQL As String
Private Const strMsg1 = "Select a product from the list"
Private Const strMsg2 = "Select a FY from the list"
Private Sub cboBeltName_AfterUpdate()
If Me!cboBeltName.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboChargeNo_AfterUpdate()
If Me!cboChargeNo.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboFY_AfterUpdate()
If Me!cboCC.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg1
End If
End Sub
Private Sub cboCC_AfterUpdate()
If Me!cboFY.Value <> "" Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Private Sub cboProjectType_AfterUpdate()
If Me!cboProjectType.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboSigmaPlusNo_AfterUpdate()
If Me!cboSigmaPlusNo.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub cboSigmaStatus_AfterUpdate()
If Me!cboSigmaStatus.Value <> "" Then
Call FillList
' Else
' Me!lblList.Caption = strMsg3
End If
End Sub
Private Sub Form_Activate()
If Me!cboFY.Value <> "" And Me!cboCC.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Private Sub FillList()
strSQL = strSQL1 & Me!cboFY.Value & _
strSQL2 & Me!cboCC.Value & _
strSQL3 & Me!cboBeltName.Value & _
strSQL4 & Me!cboChargeNo.Value & _
strSQL5 & Me!cboProjectType.Value & _
strSQL6 & Me!cboSigmaPlusNo.Value & _
strSQL7 & Me!cboSigmaStatus.Value & _
strSQL8
Me!lstOrders.RowSource = strSQL
Me!lstOrders.Requery
Me!lblList.Caption = "Orders from " & _
Me!cboFY.Value & " for " & _
Me!cboCC.Column(1)
If Me!lstOrders.ListCount = 0 Then
Me!lblList.Caption = "No " & Me!lblList.Caption
End If
End Sub
I can send the mdb if needed.
Thanks in advance. This forum is a lifesaver.