进入2007年从VBA / SQL语句列表框使用ID值 [英] Access 2007 Using the ID value from a list box in VBA/SQL statement

查看:351
本文介绍了进入2007年从VBA / SQL语句列表框使用ID值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

家伙......如果我想运行一个按钮单击事件,需要一个列表框,并使用该ID字段是在VB中的SQL语句列表框,然后就是它

Guys...if I want to run a button click event that takes a list box and uses the ID field that is in the listbox in a SQL statement in VB, then is it

me.MyListbox.selected

me.MyListbox.value

要获取的价值?由于某种原因,我曾经尝试都既不似乎工作。 .value的返回一个空值,.selected产生一个错误,说明该参数无效。

to get that value? for some reason I have tried both and neither seem to be working. .value returns an empty value, and .selected generates an error stating the argument is not valid.

谢谢 贾斯汀

推荐答案

如果该ID的绑定列和列表框没有多选,则可以使用列表框的只是名字没有任何其他限定词。如果ID不是绑定列,然后使用列属性来获取值:MyListBox.Column(n),其中n是从零开始的列数

If the ID is the bound column and the listbox is not multiselect, you can use just the name of the listbox without any other qualifier. If the ID is not the bound column, then use the column property to get the value : MyListBox.Column(n) where n is the column number starting from zero.

有关多选列表框,你需要遍历所选项目获得的列表,包括SQL使用。

For multiselect listboxes, you need to iterate through the selected items to get a list to use with SQL.

如果您正在使用的查询设计窗口或窗体或报表上的控件,你不能用我,您必须使用完整的参考(窗体!窗体名称!控件名称)或用于控制相同的形式,只是列表框中的名称。

If you are using the query design window or a control on a form or report, you cannot use Me, you must either use the full reference (Forms!Formname!ControlName) or for a control on the same form, just the name of the listbox.

这篇关于进入2007年从VBA / SQL语句列表框使用ID值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆