Hi,
Can anyone take a look and guide me where is my mistake?
Basically, I want the lbotext to populate all value based on the combobox, and single or multiple selected value in the listbox.
The code works except when the user select an item in lboUser, it still list all the items from the cboRecipient.
Please help. Thank you
Can anyone take a look and guide me where is my mistake?
Code:
Dim strRS As String
Dim lngLen As Long
Dim varItem As Variant
Dim strProd As String
strRS = "SELECT text_en, text_desc FROM qLetter WHERE"
If Not IsNull(Me.cboRecipient) Then
strRS = strRS & " recipient_id = " & Me.cboRecipient & " AND "
End If
If Not Me.lboUser.MultiSelect = 0 Then
For Each varItem In Me.lboUser.ItemsSelected
strProd = DLookup("id", "tblLetterProd", "recipient_id =" & Me.cboRecipient & " AND product_name = """ & Me.lboUser.Column(2, varItem) & """")
strRS = strRS & " product_name_id = " & strProd & " OR "
Next
End If
lngLen = Len(strRS) - 4
strRS = Left$(strRS, lngLen)
Me.lbotext.RowSource = strRS
Me.lbotext.Requery
Basically, I want the lbotext to populate all value based on the combobox, and single or multiple selected value in the listbox.
The code works except when the user select an item in lboUser, it still list all the items from the cboRecipient.
Please help. Thank you