Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 22nd, 2007, 05:34 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Default

AllenM, I cannot remember off the top of my head what I did with this, as it's quite old, but I am sure that the problem was either solved or avoided.

Thanks for the reply though.

I am sure that others may be interested in your workround.

Regards,

Sean Anderson
 
Old February 22nd, 2007, 06:04 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

If someone wishes this then just let me know.

 
Old April 17th, 2007, 11:26 AM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you getting the "Compile error: Method or data memebr not found" error at the line List1.AddItem MyObject.Collection.Item(nLoop)? if so, then I know you will get this error if you are using Access 2000 or earlier because the .additem method was not made available until access 2002. Instead populate using .rowsource property

ex.

Code:
For nLoop = 1 To MyObject.Collection.Count
     List1.RowSource = List1.RowSource & ";" & MyObject.Collection.Item(nLoop)
Next


 
Old April 18th, 2007, 11:46 AM
Registered User
 
Join Date: Apr 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure if anyone needs this, but if you are having problems with .additem i thought maybe you might be having problems with .removeItem as well. here is a code snippet i use to remove items from the list. It takes a list box as a parameter and depending on the number of column heads or columns count it will remove the selected item

Public Sub RemoveItem(lst As ListBox)
    Dim strArray() As String
    Dim i As Long
    Dim lngStart As Long
    Dim str As String

    strArray = Split(lst.RowSource, ";", , vbTextCompare)

    If lst.ColumnHeads Then
        lngStart = (lst.ColumnCount * lst.ListIndex) + lst.ColumnCount
    Else: lngStart = lst.ColumnCount * lst.ListIndex
    End If

    For i = 0 To lngStart - 1
        str = str & strArray(i) & ";"
    Next i

    For i = i + lst.ColumnCount To UBound(strArray) - 1
        str = str & strArray(i) & ";"
    Next i

    If i > UBound(strArray) Then
        lst.RowSource = Left(str, Len(str) - 1) 'remove last semicolon
    Else: lst.RowSource = str & strArray(i)
    End If
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
populate listbox from SQL server Stanny Access 1 May 30th, 2005 08:11 AM
How to: Populate Filename to listbox? mdtcao Beginning VB 6 1 May 11th, 2005 10:25 PM
active directory populate listbox new_bie C# 1 March 17th, 2005 10:31 AM
populate combo-boxs and listbox ez BOOK: Beginning Access VBA 1 June 8th, 2004 12:59 PM
Listbox doesn't populate all the records edcaru Access 1 April 25th, 2004 10:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.