LISTBOX VALUES TO TEXT BOXES

S

Songoku

Hi

I have a form which consists of 2 listboxes and a combo box. the combo box
allows the user to select a table name. When the Table is selected in
Listbox1 the fields for that Table Appear.

I have a button that when pressed moves the contents of listbox 1 to list
box 2. What I would like to be able to have is 4 hidden controls (textboxes)
that each contain a a row name from listbox 2 ie

listbox2
1
2
3
4

txtbox 1 = 1, textbox 2 = 2 etc

any suggestions appreciated....

Thnx is Advance
 
K

Klatuu

Dim varItm As Variant
Dim lngX As Long

lngX = 1
For Each varItm In Me.ListBox2.ItemsSelected
If lngX > 4 Then
Exit For
End IF
Me.Controls("TextBox" & Cstr(lngX)) = Me.ListBox2.ItemData(varItm)
lngX = lngX + 1
Next varItm
 
S

Songoku

Hi Thanks for the quick response

how about if the list box contains text ?

life savers!!!!
 
K

Klatuu

Doesn't matter. All data in controls is held as text. It is only converted
to the bound field's data type when saved.
 

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