liquidspaces
Well-known member
Im not sure what Im doing wrong here. It could be any number of things, though I suspect the SQL statement isnt doing what its supposed to.
Im trying to populate a list box whose data are determined by a previous list box. The first one lists companies. Then, depending on which one they choose, the second one will display all the invoice dates for that company. Thats what Im trying to do here.
LBto is the first list box.
Correction. I just discovered that the for loop isnt executing at all for some reason. Man, Im new at this. Dont laugh if the answers poking me in the face.
Im trying to populate a list box whose data are determined by a previous list box. The first one lists companies. Then, depending on which one they choose, the second one will display all the invoice dates for that company. Thats what Im trying to do here.
LBto is the first list box.
Correction. I just discovered that the for loop isnt executing at all for some reason. Man, Im new at this. Dont laugh if the answers poking me in the face.
Code:
Dim strSelected As String = LBTo.SelectedItem
Dim objDateDataAdapter As New OleDb.OleDbDataAdapter("SELECT DATE FROM Shipping WHERE SHIP_TO = " & ("strSelected"), OleDbConnection1)
Dim objDateCommand As New OleDb.OleDbCommandBuilder(objDateDataAdapter)
Dim objDateDataSet As New DataSet()
objDateDataSet.Clear()
objDateDataAdapter.FillSchema(objDateDataSet, SchemaType.Source, "Shipping")
objDateDataAdapter.Fill(objDateDataSet, "Shipping")
lbDate.Items.Clear()
Dim i As Integer
Dim strCurrent As String
For i = 1 To objDateDataSet.Tables("Shipping").Rows.Count
strCurrent = objDateDataSet.Tables("Shipping").Rows(i - 1).Item("DATE")
lbDate.Items.Add(strCurrent)
Next
Last edited by a moderator: