Stuart McLachlan
stuart at lexacorp.com.pg
Wed Apr 16 17:32:31 CDT 2003
Lots of ways:
Docmd.RunSQL
....
dim varItm as string
dim strBrand as string
dim strSQL as sting
For Each varItm In lstBrand.ItemsSelected
strSQL = "INSERT INTO myTable (Fld1) Select '" &
lstBrand.Column(0,varItm) & "'"
docmd.runSQl strSQL
Next varItm
....
or DAO
...
dim rs as recordset
set rs= currentdb.openrecordset("myTable")
For Each varItm In lstBrand.ItemsSelected
rs.addnew
rs(0) = lstBrand.Column(0,varItm)
rs.update
Next varItm
....
or using John's code, you can split the string into array elements
....
Dim myArray()
myArray() = Split(strbrand,",")
....
then do want you want with the array elements.
On 16 Apr 2003 at 14:51, John Clark wrote:
> But how would I take all the items and put them into another table? I
> am thinking that I'll have to write a routine to separate them and put
> them into individual records...or I will have to separate a record
> later. There are a ton of directions as to how one goes about creating
> a multisel. list, but not much as to how to manipulate the data once
> its entered.
>
> >>> papparuff at attbi.com 04/16/03 11:47AM >>>
> Using Multiselect listboxes are not as difficult as you are making
> them out to be. Here's some simple code:
>
> dim varItm as string
> dim strBrand as string
>
> strBrand = ""
> ' Get the value of the first column of all items
> ' selected in a list box
> For Each varItm In lstBrand.ItemsSelected
> strBrand = strBrand & lstBrand.Column(0, varItm) & ", "
> Next varItm
>
> John V. Ruff - The Eternal Optimist :-)
> Always Looking For Contract Opportunities
>
> "Commit to the Lord whatever you do,
> and your plans will succeed." Proverbs 16:3
>
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Clark
> Sent: Wednesday, April 16, 2003 6:50 AM To:
> accessd at databaseadvisors.com Subject: [AccessD] Multiselect List box
>
>
> I am working on a program in A2K, and I may have a need to use a
> multiselect
> list box. Actually, I think it would be best, because the choice have
> the potential to be altered in the future. However, I have never used
> multiselects before, and I am wondering how much trouble I'm getting
> into.
>
> I am all for diving in and learning something new, but I am really
> pressed for time here...this program must be put into operation by May
> 1st, and I am also playing a major part of moving an office of 200+
> people to a new building, which starts on the 24th...I have to move
> and setup their server and all routers.
>
> Should I just make the check boxes for now? Or are the multiselects
> easier than I am making them out to be?
>
> I don't think I'd have a problem with their actual setup, but taking
> the selections and putting them into the table is where I am a little
> confused.
>
> Thanks!
>
> John W Clark
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
--
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System
Support.