使用多选列表框作为查询参数-任君行
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-窗体/数据页


使用多选列表框作为查询参数

发表时间:2008/10/26 19:29:21 评论(1) 浏览(9106)  评论 | 加入收藏 | 复制
   
摘 要:我想通过ListBox控件选定的项目查询作为参数,如何做到这一点?
正 文:

( Q )我想通过ListBox控件选定的项目查询作为参数,如何做到这一点?

******************** Code Start ************************
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
    Set frm = Form!frmMyForm
    Set ctl = frm!lbMultiSelectListbox
    strSQL = "Select * from Employees where [EmpID]="
    'Assuming long [EmpID] is the bound field in lb
    'enumerate selected items and
    'concatenate to strSQL

    For Each varItem In ctl.ItemsSelected
        strSQL = strSQL & ctl.ItemData(varItem) & " or [EmpID]="
    Next varItem

    'Trim the end of strSQL
    strSQL=left$(strSQL,len(strSQL)-12))
'******************** Code end ************************


Access软件网交流QQ群(群号:198465573)
 
 相关文章
多选列表框“绑定”到字段[原创]  【goodidea  2007/10/21】
【Access源码示例】access多选列表框使用  【金宇  2012/12/3】
Access文本框列表框代替组合框的联动查询  【在水一方  2013/6/25】
命令按钮与列表框组合的菜单栏示例  【沈军  2013/7/25】
【Access示例】列表框数据的上移下移;Access整行数据移动...  【缪炜  2013/7/26】
常见问答
技术分类
相关资源
文章搜索
关于作者

任君行

文章分类

文章存档

友情链接