Cannot find list property

jjmclell

Registered User.
Local time
Today, 08:33
Joined
Aug 10, 2009
Messages
22
Hi there,

I'm trying to use the list property of a listbox in Access and VBA won't recognize the property.

Code:
 temp = Me!lst_Items.List(0, 0)
I get this error when trying to execute the above code:

'Object doesn't support this property or method.'

Any ideas?

jjmclell
 
Well, there are many properties of a list box but not one for the "list". How about the count of the number of items in the list: Me.NameOfListBox.ListCount
Or the count of the selected Items: me.NameOfListBox.ItemsSelected.Count
of the actual value of the selected item: me.NameOfListBox.value (actually you would not have to even use the .value).

The above items are correct as long as the listbox is not a multi-select listbox. That is a whole other issue.
 
What are you trying to do actually? If it is a single-select listbox, you get the value just by using

temp = Me!lst_Items
 
I have multiple columns in my list box though and the idea would be to set a variable to the value in each column, not just the bound column. I'm working on a click event where the user can move the items in the list box up or down in the list. Using the list property, from what I can understand, you're supposed to be able to read the value in listbox.list(row,column). The property is supposed to be referenced by the MS Forms 2.0 library and I have that library checked off in my references but I'm still getting the object property not supported error. I've just found the listbox.column(index,row) property though and I'm going to experiment with that...although I'd still be interested in knowing why I can't use the list property.
 
although I'd still be interested in knowing why I can't use the list property.

Because the built in listbox in Access has no LIST property. It has a ListIndex property and a Column property, but no LIST property.

And, you really should not use the Forms 2.0 controls as those are way outdated and will potentially cause you issues in the newer versions of Access.
 
Ohhh, so what you're saying Bob is that my list box is not an MS Forms 2.0 control, it's an Access control...two different things? I've been under the impression that b/c I'm working with a form in access, it must be an MS Forms 2.0 object and therefore all my controls must be MS Forms 2.0 controls.
 
Ohhh, so what you're saying Bob is that my list box is not an MS Forms 2.0 control, it's an Access control...two different things? I've been under the impression that b/c I'm working with a form in access, it must be an MS Forms 2.0 object and therefore all my controls must be MS Forms 2.0 controls.

Those are specific ActiveX controls that would be needed to be added through the Insert > ActiveX Control functionality. And I would avoid that. So, yes, if you added the controls just from the toolbar, you are dealing with native Access controls and that is good. However, the events, properties, and methods may be different that some of the ActiveX controls.
 
The ListIndex property of a listbox is "read only" and therefore it cannot be use to move the items up or down in the list.

When implementing options like this, I create a column in my table that is populated with a number for each item in the list. Then I use command buttons to allow the user to move the selected item up or down in the list and I simply re-number the items in the list using my custom numbering column.
 

Users who are viewing this thread

Back
Top Bottom