PC Review


Reply
Thread Tools Rate Thread

Additems from one listbox with multiple columns to another

 
 
=?Utf-8?B?QmlnUGln?=
Guest
Posts: n/a
 
      22nd Oct 2007
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.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      22nd Oct 2007
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
 
Reply With Quote
 
=?Utf-8?B?QmlnUGln?=
Guest
Posts: n/a
 
      22nd Oct 2007
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.
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      22nd Oct 2007
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
 
Reply With Quote
 
=?Utf-8?B?QmlnUGln?=
Guest
Posts: n/a
 
      23rd Oct 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox - multiple columns Iain Microsoft ASP .NET 3 28th Aug 2009 04:03 PM
Listbox with Multiple Columns Eddie_SP Microsoft Excel Programming 4 18th Aug 2009 05:58 PM
listbox with multiple columns ray well Microsoft VB .NET 2 31st Jul 2007 04:05 PM
Unbound LisbBox additems for two columns Vic Microsoft Access Getting Started 4 9th Nov 2003 05:16 AM
Re: Multiple ListBox columns? Ed Loubser Microsoft Dot NET 0 3rd Jul 2003 06:29 AM


Features
 

Advertising
 

Newsgroups
 


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