N
niuginikiwi
I have 2 multiselect listboxes ( lstProducts and lstRates)
I have the code below on the After Update event property of
lstProducts which requeries the rowsource of lstRates and order them
by ProductName everytime lstRates is required by selecting Product(s)
from lstProducts.
The code below does well to a certain extent, that is, when I select a
first product with i know has some Rates info that will appear on
lstRate, it doesn't appear until I select another product then it
appears. In other words, I always have to select two or more products
from lstProducts so the values in the lstRates show up.
I hope I had made this clear. Any help to get it to list the rates
after just selecting one product will be great. Thanks.
Here is the AfterUpdate event:
Private Sub lstProducts_AfterUpdate()
Dim stCtrl As ListBox
Dim strFilter As String
On Error GoTo Err_Handler
'Purpose:
Set stCtrl = Me.lstRates
'Cycle thru listbox using MultiSelectSQL function
'and assign filter variable with values selected from listbox
strFilter = "SELECT DISTINCT tblProductDetails.ProductDetailsID,
tblProductDetails.ProductID, tblProducts.ProductName,
tblProductDetails.CropRate, tblProductDetails.Rate,
tblProductDetails.RateUnit FROM tblProducts INNER JOIN
tblProductDetails ON tblProducts.ProductID=tblProductDetails.ProductID
WHERE tblProductDetails.ProductID " & MultiSelectSQL(lstProducts)
strFilter = strFilter & "ORDER BY tblProducts.ProductName"
'Requery the listbox and apply filter
stCtrl.RowSource = strFilter
stCtrl.Requery
Exit_Handler:
Exit Sub
Err_Handler:
Call LogError(Err.Number, Err.Description, conMod &
".lstProducts_AfterUpdate")
Resume Exit_Handler
End Sub
I have the code below on the After Update event property of
lstProducts which requeries the rowsource of lstRates and order them
by ProductName everytime lstRates is required by selecting Product(s)
from lstProducts.
The code below does well to a certain extent, that is, when I select a
first product with i know has some Rates info that will appear on
lstRate, it doesn't appear until I select another product then it
appears. In other words, I always have to select two or more products
from lstProducts so the values in the lstRates show up.
I hope I had made this clear. Any help to get it to list the rates
after just selecting one product will be great. Thanks.
Here is the AfterUpdate event:
Private Sub lstProducts_AfterUpdate()
Dim stCtrl As ListBox
Dim strFilter As String
On Error GoTo Err_Handler
'Purpose:
Set stCtrl = Me.lstRates
'Cycle thru listbox using MultiSelectSQL function
'and assign filter variable with values selected from listbox
strFilter = "SELECT DISTINCT tblProductDetails.ProductDetailsID,
tblProductDetails.ProductID, tblProducts.ProductName,
tblProductDetails.CropRate, tblProductDetails.Rate,
tblProductDetails.RateUnit FROM tblProducts INNER JOIN
tblProductDetails ON tblProducts.ProductID=tblProductDetails.ProductID
WHERE tblProductDetails.ProductID " & MultiSelectSQL(lstProducts)
strFilter = strFilter & "ORDER BY tblProducts.ProductName"
'Requery the listbox and apply filter
stCtrl.RowSource = strFilter
stCtrl.Requery
Exit_Handler:
Exit Sub
Err_Handler:
Call LogError(Err.Number, Err.Description, conMod &
".lstProducts_AfterUpdate")
Resume Exit_Handler
End Sub