Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box help 1

Status
Not open for further replies.

zyphac

Technical User
Mar 12, 2003
47
US
How are we all today, Good I hope. Here is what I am working with, ,I have a listbox, that uses a query to get said data, it is a multi select listbox. when I select the data it puts them in a textbox below. So as I can use it in a report.There ar 4 column is the list box, here is the problem, I need a total of 4 text boxes, one for each column here is a ex col1,col2,col3,col4 listbox
text1 text2 text3 text4 textboxes
col1 col2 col3 col4

here is the code I am useing, I can only get the data in one textbox with this:
Private Sub contractdata_GotFocus()
Me![Date].ControlSource = "=ShowContractDataSelected()"
End Sub


Public Function ShowContractDataSelected()
Dim condata As Variant
Dim fillit As String
For Each condata In Me![contractdata].ItemsSelected()
'If it is not the first item
If Len(fillit) <> 0 Then fillit = fillit & Chr(13) & Chr(10)
fillit = fillit & Me![contractdata].Column(0, condata)
Next condata
ShowContractDataSelected = fillit
End Function
is there a way to do this with muliple text boxes.
Any help would sure put this head ache at rest
thanks
zypha
 
Hi,

I don't know if I understand what you are asking, so if my response doesn't sound right then let me know! Are you trying to save each column from your listbox in a different text box?

If so this should work:
- I am assuming that you have 4 text boxes called:
Text1, Text2, Text3, Text4
- I am assuming your Listbox is called ListBoxName

Me!Text1 = [ListBoxName].column(0)
Me!Text2 = [ListBoxName].column(1)
Me!Text3 = [ListBoxName].column(2)
Me!Text4 = [ListBoxName].column(3)


HTH,

jbehrne If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Hey thanks it worked!!!!thank you, for some reason the text boxes were off, ,but I am sure I can work that one out, thank for your time, : )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top