P
Paul
I have a ComboBox and a ListBox in a form and I attached the "On Change"
event to the ComboBox so that it will find the record in the ListBox and the
record is highlighted. Is it possible for the "found" record on the ListBox
show up at the TOP of the ListBox. At present the "found" record appeals
anywhere in the ListBox and most of the time it shows up at the bottom of
the ListBox. Thanks
The "On Change" event code:
Private Sub cboProduct_Change()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT Tbl_Product.ProductID, Tbl_Product.Product,
Tbl_Inventory.StockNumber " & _
"AS [Stock Number], Tbl_Inventory_Detail.PotSize,
Tbl_Inventory_Detail.Location, " & _
"Sum(Tbl_Inventory_Detail.Quantity) AS [Total Quantity],
Tbl_Inventory_Detail.UserNotes " & _
"FROM Tbl_Product INNER JOIN (Tbl_Inventory INNER JOIN
Tbl_Inventory_Detail ON Tbl_Inventory.InventoryID " & _
"= Tbl_Inventory_Detail.InventoryID) ON Tbl_Product.ProductID =
Tbl_Inventory.ProductID " & _
"WHERE Product LIKE '" & _
Me!cboProduct.Text & "*' " & _
"GROUP BY Tbl_Product.ProductID, Tbl_Product.Product,
Tbl_Inventory.StockNumber, Tbl_Inventory_Detail.PotSize,
Tbl_Inventory_Detail.Location, Tbl_Inventory_Detail.UserNotes ORDER BY
Tbl_Product.Product, Tbl_Inventory.StockNumber;"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
rs.MoveFirst
Me!lstProduct = rs!ProductID
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
event to the ComboBox so that it will find the record in the ListBox and the
record is highlighted. Is it possible for the "found" record on the ListBox
show up at the TOP of the ListBox. At present the "found" record appeals
anywhere in the ListBox and most of the time it shows up at the bottom of
the ListBox. Thanks
The "On Change" event code:
Private Sub cboProduct_Change()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT Tbl_Product.ProductID, Tbl_Product.Product,
Tbl_Inventory.StockNumber " & _
"AS [Stock Number], Tbl_Inventory_Detail.PotSize,
Tbl_Inventory_Detail.Location, " & _
"Sum(Tbl_Inventory_Detail.Quantity) AS [Total Quantity],
Tbl_Inventory_Detail.UserNotes " & _
"FROM Tbl_Product INNER JOIN (Tbl_Inventory INNER JOIN
Tbl_Inventory_Detail ON Tbl_Inventory.InventoryID " & _
"= Tbl_Inventory_Detail.InventoryID) ON Tbl_Product.ProductID =
Tbl_Inventory.ProductID " & _
"WHERE Product LIKE '" & _
Me!cboProduct.Text & "*' " & _
"GROUP BY Tbl_Product.ProductID, Tbl_Product.Product,
Tbl_Inventory.StockNumber, Tbl_Inventory_Detail.PotSize,
Tbl_Inventory_Detail.Location, Tbl_Inventory_Detail.UserNotes ORDER BY
Tbl_Product.Product, Tbl_Inventory.StockNumber;"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
rs.MoveFirst
Me!lstProduct = rs!ProductID
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub