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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Selections from Listbox 2

Status
Not open for further replies.

zambrtp

Programmer
Jan 17, 2003
42
US

I want to be able to use a listbox with multiple selections turned on BUT I want that data ( whether its 1 or greater) to fill ONE Column field......is this possible?

So the user selects coffee, tea, milk they fill one beverage column.

 
Tereza, we could also write the value of your Listbox to a textbox on your mainform that was bound to a field in your table. That might prove easier. Add a textbox to your form and set it's control source to the field in your table. Then use this code in your CmdAdd button

Code:
Dim varItm As Variant
       Dim ctl As Control
       Dim mystr As String
       Dim strSQL As String
       Set ctl = Me.levels
         For Each varItm In ctl.ItemsSelected
           mystr = mystr & ctl.ItemData(varItm) & ","
         Next varItm
       mystr = Left(mystr, Len(mystr) - 2)
       Me.TextboxName = mystr
       DoCmd.GoToRecord , , acNewRec

You could set the visible property to No if you don't want the textbox to show. That should do it and it seems a lot easier than the other method. Let me know how it goes.

Paul




 
Paul:

OK...I am going to use the textbox idea..I see another problem...I have that listbox first and when I get to the subform..for some reason the listbox loses the data...
BUT if I go back and select it again after the subform data it works fine...Im just going to move the listbox to after the subform...
PAUL thanks for helping me these last few days...My email address is tereza_zambrano@msn.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top