Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo boxes displaying into a list box

Status
Not open for further replies.

relax4delicutfew

Programmer
Jun 29, 2004
17
US
I've created a form where I need to use combo boxes to sort the data from a query. I currently have two combo boxes that work and display the correct data, however both boxes have to be used in order to display the search. I want to be able to have the list box show the results after the first combobox, and then have the second combo box search those results further. The reason for this is that I need to add more combo boxes to the form and depending upon the search, not all of the combo boxes will be filled out.

Any help would be greatly appreciated.
 
This is my code if anyone could see what is wrong.



Private Const strSQL1 = "SELECT CaseID, Milepost, Purpose, GuardrailType, TerminalType, HardwareComments " & _
"FROM qryCombo1 WHERE RouteNumber = '"
Private Const strSQL2 = "'AND PostedSpeed = "
Private Const strSQL3 = " ORDER by Milepost ;"
Private strSQL As String

Private Sub cboRoute_AfterUpdate()
If Me!cboRoute.Value > 0 Then
Call FillList
End If
End Sub

Private Sub cboSpeed_AfterUpdate()
If Me!cboSpeed.Value > 0 Then
Call FillList
End If
End Sub

Private Sub FillList()
strSQL = strSQL1 & Me!cboRoute.Value & strSQL2 & Me!cboSpeed.Value & strSQL3
Me!lstCrashes.RowSource = strSQL
Me!lstCrashes.Requery

End Sub

Private Sub Form_Activate()
If Me!cboRoute.Value <> "" Then
Call FillList
Else
If Me!cboSpeed.Value > 0 Then
Call FillList
End If
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top