Results 1 to 11 of 11
  1. #1
    Join Date
    Nov 2003
    Posts
    24

    Unanswered: Can't add data to my Listbox with VBA

    Thounds funny, eh?
    But it isn't. I've created a query to my database which works fine, but i'm not able to add the results to the listbox in my VBA code.
    The problem is, the ListBox Class has no Subs named AddItem, RemoveItem or Clear.
    How can i operate on the Listbox without these methods?

    thanks

    P.S. I'm using Access 2000

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465

    Re: Can't add data to my Listbox with VBA

    Originally posted by dragun
    Thounds funny, eh?
    But it isn't. I've created a query to my database which works fine, but i'm not able to add the results to the listbox in my VBA code.
    The problem is, the ListBox Class has no Subs named AddItem, RemoveItem or Clear.
    How can i operate on the Listbox without these methods?

    thanks

    P.S. I'm using Access 2000
    If you want i send an Sample of that but is in Access 97 you must convert to Access 2000...??
    Saludos
    Norberto

  3. #3
    Join Date
    Nov 2003
    Posts
    24
    this will help me alot,
    thanks

  4. #4
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by dragun
    this will help me alot,
    thanks
    Ok this is the sample in Access 97.
    Attached Files Attached Files
    Saludos
    Norberto

  5. #5
    Join Date
    Nov 2003
    Posts
    24
    thanks, your demo works fine, but unfortunatelly i have no time now to analyze the code. I recall you if i've any problems.

    by

  6. #6
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Ok....
    Feliz Navidad
    Saludos
    Norberto

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    ListBoxes for Access 2000 and before do not have the AddItem method like 2002 does ... You have to use the Value List and Row Source concatenation or build a table/query that populates the ListBox.

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by M Owen
    ListBoxes for Access 2000 and before do not have the AddItem method like 2002 does ... You have to use the Value List and Row Source concatenation or build a table/query that populates the ListBox.
    You beat me to it!

    The easiest way to do this is to create your own function that will accept a string parameter and the listbox object to perform the append for you.

    I have one that I made laying around somewhere. I'd have to do quite a bit of digging to find it though

  9. #9
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Teddy
    You beat me to it!

    The easiest way to do this is to create your own function that will accept a string parameter and the listbox object to perform the append for you.

    I have one that I made laying around somewhere. I'd have to do quite a bit of digging to find it though
    Ted,

    BIG PROBLEM tho ... the available space of the row source is only 2K ... So if the items to be added will total to lesss than 2K it's fine. 1 character over that and you might as well make a temp table to store the listbox values in and query from that.

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by M Owen
    Ted,

    BIG PROBLEM tho ... the available space of the row source is only 2K ... So if the items to be added will total to lesss than 2K it's fine. 1 character over that and you might as well make a temp table to store the listbox values in and query from that.
    No problems, only challenges!!

    I'm not sure what the exact correlation between the character limit and the physical memory is, but once you have that hammered out you could create a small routine within that function to test for size of each entry and pare it down accordingly.

  11. #11
    Join Date
    Nov 2003
    Posts
    24
    Unfortunately it isn't a challenge, it is a problem. I've created a routine checking the stringsize thus 2k=2048Bytes is the limit. (Tested it with 2049 Bytes and it crashed ).
    At the beginnig it was ok, but unfortunatelly i need multiple columns thus in some forms (depending on the data) i can just view 5 or 6 entrys out of some thousands and i can't shorten the entries in the listbox cause they are realy needed .
    BUT it seems like Access 2000 has a fucking bug. I've created for some special purposes my own ActiveX Components in C++, but when trying to use them directly in my codes failed cause the components weren't found. But using the form wizard i was able to choose my ActiveX Component. Afterwards the whole lib of the new Component was visible in the Code-Editor. Next I've tried the same with the Microsoft Forms 2.0 Listbox. (Installed with Access 2000 don't know whether Access 97 has the lib to, just search for the file 'fm20.dll'). And Hell the Library 'MSForms' was visible in the code Editor and I had a second Listbox Object provided by the MSForms Lib
    BUT (yeah there is a 2nd but) I wasn't able to use the multicolumn features correctly.
    Using the function AddItem i was just able to add a new item to the next row, but no item was added to the other columns (i've tested it with ';' and Tabs). Fortunately I was able to fill the next columns with the property Column:
    Code:
    list.Column(colIndex, RowIndex) = value
    And now the BIG PROBLEM:
    I'm not able to fill the columnhead. I can use ColumnCount=..., ColumnHeads=TRUE to show a column Header, but there is no RowSource Property thus i'm not able to fill the ColumnHead. IS there anybody who knows how to solve the Problem (No, i don't want to hide the ColumnHeads) ?

    bye

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •