Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Additems from one listbox with multiple columns to another

Hello All,

I am trying to add selected items from one listbox to another on the same
form. I get this error when running the code below: Run-time error '381':
Could not set the list property. Invalid property array index.

Here's the code: Where the form is frm_billing_screen, the listbox that I
want to retrieve data from is lst_bs_school and the listbox that I want to
additems to is lst_bs_bm. lst_bs_school has a rowsource, but the other does
not. I'm hoping you're not going to tell me that I can't use the rowsource
property for the one listbox.

With frm_billing_screen
Dim x As Integer
For x = 0 To .lst_bs_school.ListCount - 1

..lst_bs_bm.Clear
..lst_bs_bm.ColumnCount = 6
..lst_bs_bm.ColumnWidths = "49.95 pt;75 pt;60 pt;49.95 pt;40 pt;100 pt"

If .lst_bs_school.Selected(x) = True Then
..lst_bs_bm.AddItem .lst_bs_school.List(x, 0)
..lst_bs_bm.List(x, 2) = .lst_bs_school.List(x, 1)
..lst_bs_bm.List(x, 3) = .lst_bs_school.List(x, 2)
..lst_bs_bm.List(x, 4) = .lst_bs_school.List(x, 3)
..lst_bs_bm.List(x, 5) = .lst_bs_school.List(x, 4)
..lst_bs_bm.List(x, 6) = .lst_bs_school.List(x, 5)
..lst_bs_school.Selected(x) = False
End If
Next
End With

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Additems from one listbox with multiple columns to another

Maybe you assigned a .list in code or while you were designing the form.

I'd add one more line:

....
..lst_bs_bm.Clear
..lst_bs_bm.list = "" '<-- Added
....

BigPig wrote:

Hello All,

I am trying to add selected items from one listbox to another on the same
form. I get this error when running the code below: Run-time error '381':
Could not set the list property. Invalid property array index.

Here's the code: Where the form is frm_billing_screen, the listbox that I
want to retrieve data from is lst_bs_school and the listbox that I want to
additems to is lst_bs_bm. lst_bs_school has a rowsource, but the other does
not. I'm hoping you're not going to tell me that I can't use the rowsource
property for the one listbox.

With frm_billing_screen
Dim x As Integer
For x = 0 To .lst_bs_school.ListCount - 1

.lst_bs_bm.Clear
.lst_bs_bm.ColumnCount = 6
.lst_bs_bm.ColumnWidths = "49.95 pt;75 pt;60 pt;49.95 pt;40 pt;100 pt"

If .lst_bs_school.Selected(x) = True Then
.lst_bs_bm.AddItem .lst_bs_school.List(x, 0)
.lst_bs_bm.List(x, 2) = .lst_bs_school.List(x, 1)
.lst_bs_bm.List(x, 3) = .lst_bs_school.List(x, 2)
.lst_bs_bm.List(x, 4) = .lst_bs_school.List(x, 3)
.lst_bs_bm.List(x, 5) = .lst_bs_school.List(x, 4)
.lst_bs_bm.List(x, 6) = .lst_bs_school.List(x, 5)
.lst_bs_school.Selected(x) = False
End If
Next
End With

Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Additems from one listbox with multiple columns to another

Hi David,


"Dave Peterson" wrote:

Maybe you assigned a .list in code or while you were designing the form.

I'd add one more line:

....
..lst_bs_bm.Clear
..lst_bs_bm.list = "" '<-- Added
....


I tried as you suggested. Checked over the rest of my code and the listbox
properties, but didn't see anything.
I received the same error as before but with: ..lst_bs_bm.list="". Took it
out and tried again, but still the same error on the same line:
..lst_bs_bm.List(x, 2) = .lst_bs_school.List(x, 1)

If I take out all the entries other than additem (.list..), it adds as it
should but only in the 1st column (out of 6).

Thank you, your advice is always appreciated.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Additems from one listbox with multiple columns to another

What line causes the error?

I didn't notice this before, but I think you'll want to change this portion:

If .lst_bs_school.Selected(x) = True Then
.lst_bs_bm.AddItem .lst_bs_school.List(x, 0)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 2) = .lst_bs_school.List(x, 1)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 3) = .lst_bs_school.List(x, 2)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 4) = .lst_bs_school.List(x, 3)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 5) = .lst_bs_school.List(x, 4)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 6) = .lst_bs_school.List(x, 5)
'.lst_bs_school.Selected(x) = False
End If




BigPig wrote:

Hi David,

"Dave Peterson" wrote:

Maybe you assigned a .list in code or while you were designing the form.

I'd add one more line:

....
..lst_bs_bm.Clear
..lst_bs_bm.list = "" '<-- Added
....


I tried as you suggested. Checked over the rest of my code and the listbox
properties, but didn't see anything.
I received the same error as before but with: ..lst_bs_bm.list="". Took it
out and tried again, but still the same error on the same line:
.lst_bs_bm.List(x, 2) = .lst_bs_school.List(x, 1)

If I take out all the entries other than additem (.list..), it adds as it
should but only in the 1st column (out of 6).

Thank you, your advice is always appreciated.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Additems from one listbox with multiple columns to another

Thank you Dave.

"Dave Peterson" wrote:

What line causes the error?

I didn't notice this before, but I think you'll want to change this portion:

If .lst_bs_school.Selected(x) = True Then
.lst_bs_bm.AddItem .lst_bs_school.List(x, 0)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 2) = .lst_bs_school.List(x, 1)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 3) = .lst_bs_school.List(x, 2)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 4) = .lst_bs_school.List(x, 3)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 5) = .lst_bs_school.List(x, 4)
.lst_bs_bm.List(.lst_bs_bm.listcount-1, 6) = .lst_bs_school.List(x, 5)
'.lst_bs_school.Selected(x) = False
End If


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting corresponding columns on a multiple select listbox [email protected] Excel Programming 0 July 25th 06 03:37 PM
adding multiple columns to a listbox ndm berry[_2_] Excel Programming 2 October 10th 05 09:13 AM
multiple columns / rows to be referenced through a listbox Hru48 Excel Discussion (Misc queries) 0 July 4th 05 04:12 PM
Selecting multiple items and columns from ListBox TK Excel Programming 0 August 25th 04 01:19 AM
Multi-column ListBox. Multiple bound columns??? Joe Mathis Excel Programming 5 December 10th 03 01:32 AM


All times are GMT +1. The time now is 02:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"