C
cesemj
Hello,
Cann someone explaine to me why I am unable to show the data in the
list box after I made a selection in the second combo box. When I
compile the code I do not get any errors and when I open the form no
errors.
I used an example from a access pgm called VBA combo as refference for
the list box and microsoft artle about sync two combo boxes.
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT Uic, Jcn, csmp_narrative_summary,
when_discovered_date, maint_quarter " & _
"FROM qryListBox WHERE ship_class = '"
Private Const strSQL2 = "' AND ship_type_hull = "
Private Const strSQL3 = " ORDER BY when_discovered_date DESC;"
Private strSQL As String
Private Const strMsg1 = "Select a Ship Hull from the list"
Private Const strMsg2 = "Select a Ship Class from the list"
Private Sub FillList()
strSQL = strSQL1 & Me!cboShipClass.Value & _
strSQL2 & Me!cboShipHull.Value & strSQL3
Me!lstOrders.RowSource = strSQL
Me!lstOrders.Requery
Me!lblList.Caption = "Data From " & _
Me!cboShipClass.Value & " For " & _
Me!cboShipHull.Column(1)
If Me!lstOrders.ListCount = 0 Then
Me!lblList.Caption = "No " & Me!lblList.Caption
End If
End Sub
Private Sub cboShipClass_AfterUpdate()
Me.cboShipHull = Null
Me.cboShipHull.Requery
Me.cboShipHull = Me.cboShipHull.ItemData(0)
If Me!cboShipHull.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg1
End If
End Sub
Private Sub cboShipHull_AfterUpdate()
If Me!cboShipClass.Value <> "" Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Private Sub Form_Current()
Me.cboShipHull.Requery
End Sub
Private Sub Form_Load()
Me.cboShipClass = Me.cboShipClass.ItemData(0)
Call cboShipClass_AfterUpdate
End Sub
Private Sub Form_Open(Cancel As Integer)
'With Me
'.cboShipClass = ""
'.cboShipHull = ""
'End With
End Sub
Private Sub Form_Activate()
If Me!cboShipClass.Value <> "" And Me!cboShipHull.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Cann someone explaine to me why I am unable to show the data in the
list box after I made a selection in the second combo box. When I
compile the code I do not get any errors and when I open the form no
errors.
I used an example from a access pgm called VBA combo as refference for
the list box and microsoft artle about sync two combo boxes.
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT Uic, Jcn, csmp_narrative_summary,
when_discovered_date, maint_quarter " & _
"FROM qryListBox WHERE ship_class = '"
Private Const strSQL2 = "' AND ship_type_hull = "
Private Const strSQL3 = " ORDER BY when_discovered_date DESC;"
Private strSQL As String
Private Const strMsg1 = "Select a Ship Hull from the list"
Private Const strMsg2 = "Select a Ship Class from the list"
Private Sub FillList()
strSQL = strSQL1 & Me!cboShipClass.Value & _
strSQL2 & Me!cboShipHull.Value & strSQL3
Me!lstOrders.RowSource = strSQL
Me!lstOrders.Requery
Me!lblList.Caption = "Data From " & _
Me!cboShipClass.Value & " For " & _
Me!cboShipHull.Column(1)
If Me!lstOrders.ListCount = 0 Then
Me!lblList.Caption = "No " & Me!lblList.Caption
End If
End Sub
Private Sub cboShipClass_AfterUpdate()
Me.cboShipHull = Null
Me.cboShipHull.Requery
Me.cboShipHull = Me.cboShipHull.ItemData(0)
If Me!cboShipHull.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg1
End If
End Sub
Private Sub cboShipHull_AfterUpdate()
If Me!cboShipClass.Value <> "" Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub
Private Sub Form_Current()
Me.cboShipHull.Requery
End Sub
Private Sub Form_Load()
Me.cboShipClass = Me.cboShipClass.ItemData(0)
Call cboShipClass_AfterUpdate
End Sub
Private Sub Form_Open(Cancel As Integer)
'With Me
'.cboShipClass = ""
'.cboShipHull = ""
'End With
End Sub
Private Sub Form_Activate()
If Me!cboShipClass.Value <> "" And Me!cboShipHull.Value > 0 Then
Call FillList
Else
Me!lblList.Caption = strMsg2
End If
End Sub