cascading listbox in word vba userform

I

iris

I need to feed a textbox when I click an item in a listbox.



I have a userform in word with 1 listbox and 3 textboxes.



the database is an access database with 7 columns.



I am initializing the listbox with 7 columnbound columns.





this is my code:



Private Sub UserForm_Initialize()



On Error Resume Next



Dim dbDatabase As Database

Dim rsd As Recordset

Dim d As Integer

Set dbDatabase = OpenDatabase("C:\nihul.mdb")



Set rsd = dbDatabase.OpenRecordset("SELECT * FROM expressions ORDER BY
heb;", dbOpenSnapshot)



ListBox1.Clear

d = 0

With rsd



Do Until .EOF

ListBox1.AddItem (d)

ListBox1.ColumnCount = 3

ListBox1.BoundColumn = 7

ListBox1.ColumnWidths = "4 in;4 in;0.5 in;"

ListBox1.Column(6, d) = ![hebrt]



ListBox1.Column(0, d) = ![heb]



ListBox1.Column(1, d) = ![eng]

ListBox1.Column(2, d) = ![engRT]



.MoveNext

d = d + 1

Loop

End With



rsd.Close

dbDatabase.Close



Set rsd = Nothing

Set dbDatabase = Nothing



End Sub



after initializing the list box, I want to click on an item in the listbox
and see the coloumnbound data from the database in the 3 textboxes (each
column in an other textbox).





Thank you in advance for your help!



Iris
 

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

Similar Threads


Top