Access 2007 Using the ID value from a list box in

2019-09-06 07:53发布

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

or

me.MyListbox.value

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.

thanks justin

1条回答
做个烂人
2楼-- · 2019-09-06 08:27

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.

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.

查看更多
登录 后发表回答