how to populate the selected item in listbox in text in MS-Acces.

G

Gerald

Hi All,

This is the below I am trying to get selected item to be shown in the
textbox. Works fine in VB6.0.. But not in MS-Access 2002.

Private Sub Command42_Click()
Text1.Text = List1.list(List1.ListIndex)
Select Case List1.ListIndex

Case 0
Text1.Text = "MOO"
Case 1
Text1.Text = "CHO"
Case 2
Text1.Text = "KKK"

End Select
End Sub

Thanks
 
G

Graham Mandeno

Hi Gerald

It would help if you told us *how* it is not working. For example, what
error message, which line in the code, etc, and also what it is you are
trying to achieve.

However, I can tell you that the behavoiur of Access controls is different
in many ways from those in VB6. For a start, the Text property of a textbox
is accessible only when the textbox has the focus. It represents the
"unupdated" text in the control. For your purpose you should use the Value
property (which is the default property).

Also, listboxes and combo boxes have a Value property which represents the
value of the bound column in the currently selected row. If your listbox
has two columns, in the rowsource, with values like:
0 MOO
1 CHO
2 KKK
and the BoundColumn is 1, then if the second row is selected then
List1.Value will be 1.

There is also a Column property (zero-based) so List1.Column(1) will be
"CHO"

There is also no List property for a listbox.

I suspect all you need in your code is:
Text1 = List1.Column(1)

However, the information above should be enough to get you going if I've
misunderstood your requirement.
 

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