cascading listboxs

I

iris

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

the database is an access database.

I am initializing the listbox with 7 columnbound coloumns.


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
coloumn in an other textbox).

I saw Gregs explenation in his internet site but I can't figure out how to
do this with database instead of an array...

Thank you in advance for your help!

Iris
 
D

Doug Robbins - Word MVP

Look at the two examples of loading a listbox from Access on the following
page of Greg's website:

http://gregmaxey.mvps.org/Populate_UserForm_ListBox.htm

Note, if you set the .ColumnCount to 3, you cannot then set the .BoundColumn
to 7

--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my
services on a paid, professional basis.
 

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