Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Listbox Problem using List Property - Missing Reference?

Posted on 2011-09-16
3
Medium Priority
?
439 Views
Last Modified: 2012-05-12
Hi Experts,

I'm trying to use an array to populate a listbox, however the 'list' property is causing 'Run-time error 438 - Object doesn't support this property or method'.  The code below is that provided in Microsofts Help and the following line is the affending one.
ListBox1.List() = MyArray

I'm using MS Access 2007.

I can only think that I have a missing reference or something.  Any suggestions?

Many Thanks,

Oliver
Dim MyArray(6, 3)           

'Array containing column values for ListBox.



Private Sub UserForm_Initialize()

    Dim i As Single



    ListBox1.ColumnCount = 3        

'This list box contains 3 data columns



    'Load integer values MyArray

    For i = 0 To 5

        MyArray(i, 0) = i

        MyArray(i, 1) = Rnd

        MyArray(i, 2) = Rnd

    Next i



    'Load ListBox1

    ListBox1.List() = MyArray



End Sub

Open in new window

0
Comment
Question by:Oliver Wastell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1200 total points
ID: 36550796
Are you doing this in Access? If so, then an Access Listbox doesn't have the List propery. If you're going to populate a Listbox like this, set the RowSourceType to "Value List", the ColumnCount to 3, and your ColumnWidths to 1;1;1. Then add your items using the .AddItem method:

 For i = 0 To 5

       Me.Listbox.AddItem i & ";" & Rnd & "';" & Rnd

    Next i

0
 
LVL 34

Accepted Solution

by:
Norie earned 800 total points
ID: 36550827
Oliver

You can't use List in Access.

There's also no userforms in Acess and therefore no userform Initialize event.

If you do have an unbound form in Access with a 3-column listbox you can populate it like this.

Option Compare Database
Option Explicit

Private Sub Form_Load()
Dim I As Long

    Listbox1.RowSourceType = "Value List"
    Listbox1.ColumnCount = 3

    For I = 0 To 5
        Listbox1.AddItem I & ";" & Rnd & ";" & Rnd
    Next I

End Sub

Open in new window

0
 
LVL 3

Author Closing Comment

by:Oliver Wastell
ID: 36552096
Hi LSM Consulting / imnorie,

Thank you both for you quick replies, only a few minutes between you.    Both your solutions are clear.  I've awarded 300 to LSM Consulting for being slightly quicker off the mark, and 200 to imnorie.  I hope you both deem this fair.

Best Regards and Thanks!

Oliver
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question