Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

multiple names to a field using list box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
b_a_redman - 29 Jun 2007 11:04 GMT
Ok, i have a mulitple selection listbox, i want to store the selected values
into one field with each value seperated by a comma in the field. Im not
interested about how it is not good practice and how it is not good to do. I
just want this feature on my form, i have no knowledge of VBA, so if somehow
has the know how to do it. Can you please help me and provide the code for me?
Scott McDaniel - 29 Jun 2007 11:54 GMT
>Ok, i have a mulitple selection listbox, i want to store the selected values
>into one field with each value seperated by a comma in the field. Im not
>interested about how it is not good practice and how it is not good to do. I
>just want this feature on my form, i have no knowledge of VBA, so if somehow
>has the know how to do it. Can you please help me and provide the code for me?

A multiselect listbox exposes the .ItemsSelected property, so you can do this:

Dim v As Variant
Dim sData as string

For each v in YourLIstbox.ItemsSelected
 sData = YourListBox.ItemsSelected(v) & "," sData
Next v

sData = left(sDAta, Len(sData)-1)

CurrentProject.Connection.Execute "UPDATE SomeTable SET YourMultiValueField='" & sData & "' WHERE SomeIDField=" &
Me.YourIDField

I realize you don't want to hear about storing multiple values in a field, but it's wrong, wrong, wrong ... there is no
easy way to search this field, and a 1-M relationship should be stored in separate tables ... but if ya wanna hose up
your data, be my guest!!

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.