Results 1 to 3 of 3

Thread: MS Access

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298
    I need a little help with an MS Access problem.

    I have one list box 'lst1' which looks up values from another table containing mechanical qualifications.

    My second list box 'lst2' receives values from lst1 via a button which copies the selected values from lst1 to lst2.

    I can't seem to get lst2 to retain the values that are sent to it via the button.

    Help would be appreciated.

    Also from lst2 I'd like to be able to remove selected values from time to time. The .removeitem doesn't seem to work and I'm kinda stuck now for new ideas.

  2. #2
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201
    In order to help you with the first question I would like to see some code if possible. Than I know what your doing.

    For the second it's importante to now wich index the item has. I it's the selectded one you will have to use the listindex property of the listbox to find out.
    When it isn't the selected item than it's usefull to create an array of the items that also has the the index of each item. Then you can look it up in the array using the discription of the item and take the index to the removeitem property.
    I hope this is usefull information and that you will use it wisely.

    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Code

    This is the OnClick command Code to copy values from one list box 'lst1' to 'lst2'

    Private Sub cmdAddList_Click()
    Dim lst1 As ListBox, lst2 As ListBox

    Dim itm As Variant

    Set lst1 = Me!lstSource
    Set lst2 = Forms!frmEmployees!frmQualificationsSubform!txtQualifications
    ' Check selected items.
    For Each itm In lst1.ItemsSelected
    ' Set RowSource property for first selected item.
    If lst2.RowSource = "" Then
    lst2.RowSource = lst1.ItemData(itm)
    Else
    ' Check whether item has already been copied.
    If Not InStr(lst2.RowSource, lst1.ItemData(itm)) > 0 Then
    lst2.RowSource = lst2.RowSource & ";" & lst1.ItemData(itm)
    End If
    End If
    Next itm
    End Sub



    That code works fine.

    What I need is to get a list box namely 'lst2' to retain the values it receives via the above.

Posting Permissions

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



Click Here to Expand Forum to Full Width