[VBA]Problem with subforms and ListBoxes

B

ByB

Hello,

I am developping an Access/VBA application. In this app, I creatd a
from (let call it A) and a subform (let call it B).

The form A has 15 occurences of the subform B in it.

The subform B has a ListBox control, with 3 possible values to display
(arrow up, arrow neutral and arrow down). Let call the ListBox LB.

I need to change the item displayed in the ListBox of each 15
occurences of the subform accordingly to the value of the data found in
the 15 rows of a recordset. Let call the value "myvalue". myvalue is
between 0 and 2.

I tried to make the change in the ListBoxes by using KB.ListItem =
myvalue, but I have an error message saying that it's a bad use of
ListItem.

I tried with LB.Selected(myvalue) = True, but the error message says
that Selected property does not exist.

I tried with LB.SelectedItem = myvalue, and the result is the same.

Can somebody help me and tell me how can I select the item displayed in
the ListBoxes of my subform ? Thank a lot for any help !
 
C

Carl Rapson

ByB said:
Hello,

I am developping an Access/VBA application. In this app, I creatd a from
(let call it A) and a subform (let call it B).

The form A has 15 occurences of the subform B in it.

The subform B has a ListBox control, with 3 possible values to display
(arrow up, arrow neutral and arrow down). Let call the ListBox LB.

I need to change the item displayed in the ListBox of each 15 occurences
of the subform accordingly to the value of the data found in the 15 rows
of a recordset. Let call the value "myvalue". myvalue is between 0 and 2.

I tried to make the change in the ListBoxes by using KB.ListItem =
myvalue, but I have an error message saying that it's a bad use of
ListItem.

I tried with LB.Selected(myvalue) = True, but the error message says that
Selected property does not exist.

I tried with LB.SelectedItem = myvalue, and the result is the same.

Can somebody help me and tell me how can I select the item displayed in
the ListBoxes of my subform ? Thank a lot for any help !

Try this:

LB = myvalue

Carl Rapson
 
B

ByB

Try this:
LB = myvalue
Carl Rapson


Thank you for this hint.

Now tell me why they have put ListItem as readonly in VBA for Access
????!!!!!

To select the first element in the ListBox the answer was :
LB = LB.ItemData(0)
For the second item :
LB = LB.ItemData(1)
etc.

Found it on the Internet, after 2 day of Googling ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top