Designing Extended Multi-Select List Boxes

While designing a database in Access 2000 recently, I decided the most intuitive way for my users to be able to look at the data they wanted was to let them use extended multi-select list boxes to pick the information they wanted. The function below converted their selections into a clause that appended to an SQL WHERE statement, creating or modifying a query. This function can also be used as a filter to open a form or report. Since the values passed were always strings, and the first column of the list boxes always contained unique values, I built the column number and delimiters into the function, where they could easily be replaced by Optional variables. If nothing is selected, this function will return an empty string. While this code was written specifically for Access 2000, it should also work in Access 97, Excel 5.0 on up, and Visual Basic.

 Public Function WHEREFromListbox(lst As ListBox,strField As String) As String' Created by Carolyn J. Howorth, August 29, 2000' Returns a SQL WHERE Clause from a multi-selectlistbox' Note that WHERE is not included so that thisfunction can'   be used as a filter in Access        For intLp = 0 To lst.ListCount        If lst.Selected(intLp) = True Then            If Len(strResult) > 1 Then                WHEREFromListbox = WHEREFromListbox &

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS