Multi selection in List Box

  • Thread starter Thread starter Berny
  • Start date Start date
B

Berny

Can anyone point me in the right direction (samples) on how to code multi
seletions in a Forms list box that filters the criteria in a report?
 
Berny said:
Can anyone point me in the right direction (samples) on how to code multi
seletions in a Forms list box that filters the criteria in a report?

[Replay]
Suppose:

1)[lstControlName] is the ListBox referenceName
2)[strCriteria] can be " AND " or " OR "..... remember space before and
after
3)I suppose that filedType is Text, if Numeric remove chr(34)
Dim MyCriteria as String
MyCriteria=retFilter("FieldName", " AND ")

Use this string to put it on WHERE condition of OPENREPORT method


'---------------------------------------------------------------------------
--------------------
Private Function retFilter(fieldName as string, strCriteria as string) as
string
Dim vItm As Variant
Dim stWhat As String
Dim stCriteria As String
stWhat = ""
For Each vItm In Me.lstControlName.ItemsSelected
stWhat = stWhat & "[" & fieldName & "]=" & chr(34) &
Me.lstPrint.ItemData(vItm) & chr(34) & stCriteria
Next vItm
retFilter=Mid$(stWath, 1, Len(stWath)-Len(strCriteria))
End Function

Hope this help you.
 
Back
Top