Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gerald - 29 Mar 2005 11:23 GMT
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
Graham Mandeno - 29 Mar 2005 11:49 GMT
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.
Signature

Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

> Hi All,
>
[quoted text clipped - 16 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.