Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB 6.0 & Access Listbox Question

Options
  • 14-06-2002 12:25pm
    #1
    Closed Accounts Posts: 57 ✭✭


    Hi, I need to clear a listbox on a form in Microsoft Access Visual Basic 6.0. MSDN, and other webpages suggest that I use the Listbox.Clear or Listbox.RemoveItem methods to do this. However, they don't seem to be implemented in the Listbox object in any of the Libraries I have. How do I get Listbox.Clear working? Is there a particular library I must download/install and if so, where do I get it from?!


Comments

  • Registered Users Posts: 15,258 ✭✭✭✭Rabies


    you shouldnt need to download anything....
    it sounds to me as if it is just a syntax error...

    Clear (Clipboard, ComboBox, ListBox)
    This method clears the contents of a ListBox object, ComboBox object, or the system Clipboard object.

    object.Clear

    Parameters
    object
    Reference to a ListBox, ComboBox, or Clipboard object
    Remarks
    To remove a single item from a ListBox or ComboBox, use the RemoveItem method.

    RemoveItem
    This method removes an item from a ListBox, ComboBox, or Grid control.

    control.RemoveItem index
    Parameters
    control
    Required. Object expression that is a ListBox, ComboBox, or Grid control.
    index
    Required. Long expression that represents the position of the item or row to remove within the object. For the first item in a ListBox or ComboBox or for the first row in a Grid control, index = 0.
    Return Value
    None.

    Remarks
    RemoveItem removes only one item. To remove all items, use the Clear method.

    The RemoveItem method for the Grid control deletes the entire row specified. To clear data without removing the rows themselves, use the Clear method.


  • Closed Accounts Posts: 57 ✭✭dumb larry


    Nah, it's not a syntax error. I type the name of the listbox (lbxSoftwareList) followed by a period - lbxSoftwareList.
    Up pops the little menu - and there's no Clear or RemoveItem to be found in it. I took a look at the ListBox object in the object browser, but the method's I'm looking for aren't listed there either. I'm using Access and the ListBox object itself is listed as 'Member of Access'.


  • Closed Accounts Posts: 57 ✭✭dumb larry


    Actually, where do I download Microsoft VB libraries from? I might be able to get a different lib and try that. Maybe the one they gave with Access is a 'lite' version or something.


  • Registered Users Posts: 2,781 ✭✭✭amen


    After a bit of searching it appears that
    there is not a clear/remove item method in Access for clearing listboxes.

    Definatley is in VB object.clear works
    for Access you need to do something a bit different (note I'm not an Access expert so prehaps someone else might have a better solution)

    try

    listbox.rowsource=""

    that will blank all you entires because you have removed the record source
    to reapply them just you
    listbox.rowsource=myrecordsource

    hoep that helps


  • Registered Users Posts: 15,258 ✭✭✭✭Rabies


    After a bit of searching it appears that
    there is not a clear/remove item method in Access for clearing listboxes.

    Definatley is in VB object.clear works
    for Access you need to do something a bit different (note I'm not an Access expert so prehaps someone else might have a better solution)

    i found same result..... what i posted earlier was for VB. i expected it to work with access.
    i was wrong.

    just checked access help for "list boxes, properties" and there is no 'clear' or 'removeitem'....


  • Advertisement
  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Ahhh - good old AccessBasic. Just enough like VB to make VB-heads feel at home. Just different enough to then make the VB-heads scream in frustration.

    I hate listboxes in Access. They are the most ugly SOBs to code against. (I think the rowsource approach works, BTW).

    jc


Advertisement