CrossPosat - Multiple Criteria in a List Box

G

Guest

I Posted This in "General Question:...but no replies..Thanks for any
assistance here.

Thanks to Allen Browne for a code example in using a List Box.

Part of the code included...
strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","

No problem building that from multiple selections from the List Box.

What I need is...from...
WHERE (((ABilling.MemStatus)=[Forms]![New Members]![AMemLists]) AND
((Left([LastName],1))=[Forms]![New Members]![ForBill]))....

The "AMemLists" is a Member Year (IE = 2007). I need to build multiple...
((Left([LastName],1))=[Forms]![New Members]![ForBill])), where it would be
like...

Left([LastName],1)="A" Or Left([LastName],1)="B" Or
Left([LastName],1)="C"...etc.


Back to Allen's example...
Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[CategoryID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If

....where I open the Report with...

DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip

TIA - Bob
 
G

Guest

Duane - thank you.

Bob

Duane Hookom said:
I would expect to see some code that loops through the list box selected
items but it isn't in the code you provided. There is a generic function at
http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane which can
be used to create a query based on a multiple select list box.

--
Duane Hookom
Microsoft Access MVP


Bob Barnes said:
I Posted This in "General Question:...but no replies..Thanks for any
assistance here.

Thanks to Allen Browne for a code example in using a List Box.

Part of the code included...
strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","

No problem building that from multiple selections from the List Box.

What I need is...from...
WHERE (((ABilling.MemStatus)=[Forms]![New Members]![AMemLists]) AND
((Left([LastName],1))=[Forms]![New Members]![ForBill]))....

The "AMemLists" is a Member Year (IE = 2007). I need to build multiple...
((Left([LastName],1))=[Forms]![New Members]![ForBill])), where it would be
like...

Left([LastName],1)="A" Or Left([LastName],1)="B" Or
Left([LastName],1)="C"...etc.


Back to Allen's example...
Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[CategoryID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If

...where I open the Report with...

DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip

TIA - Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top