Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MultiSelect Listbox - Refer to Column? (2000)

    How do I refer to a multi select listbox's columns in code? When I select more than one item in the listbox and click at button the code runs. This code is to open a recordset, search the recordset for an array (column0 and column1 of the listbox), and then if it finds it, delete it from the recordset. And it's to do this for each item selected in the list box. Below is the code for the search and delete. I know the problem is I'm referring to the listboxes selected column and not referring to each selected item's column. HOw do I do this? Thanks, Sarah
    =================================
    With rs
    For Each varitm In ctl.ItemsSelected
    ListCol0 = ctl.Column(0)
    ListCol1 = ctl.Column(1)
    For intI = 0 To ctl.ColumnCount - 4
    .Requery
    .Index = "PrimaryKey"
    .Seek Array(ListCol1, ListCol0), adSeekFirstEQ
    If (Not .BOF And Not .EOF) Then
    .Delete
    End If
    Next intI
    Next varitm

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: MultiSelect Listbox - Refer to Column? (2000)

    You have to refer to both the row and column of the item in the ItemsSelected collection. Try this:

    For Each varitm In ctl.ItemsSelected
    ListCol0 = ctl.Column(0, varitm )
    ListCol1 = ctl.Column(1,varitm )
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MultiSelect Listbox - Refer to Column? (2000)

    Hey Charlotte, Thanks! Your suggestion worked great.

    I knew I was close, but wasn't sure what I was missing.

    Thanks again.
    Sarah

Posting Permissions

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