Results 1 to 12 of 12

Thread: listbox help

  1. #1
    Join Date
    Dec 2003
    Posts
    26

    Unanswered: listbox help

    Can help me with a little problem.

    I have a table called installedSoftware which has two fields:
    ComputerID
    SoftwareID

    and another table called softwareListTable
    SoftwareID
    Description
    Price
    etc

    I have a listbox on the left hand side with all the values from softwareListTable and a listbox on the right hand side which contain all the records/values from installedSoftwareTable

    What I want to do is have a couple of buttons in the middle that can select items from the left and place them in the right and a button when that removes them as well. (It should look some thing like the autoform wizzard when you are selecting fileds)
    Can any one help

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    If you are using Access 2000 or greater, do the following:

    In the GotFocus and LostFocus events of each ListBox, set the enabling or disabling of your Transfer/Remove buttons accordingly.

    For moving from List1 to List2 place this code into OnClick event of the button that would carry out this transfer:

    Code:
    If Not IsNull(Me.List1.Column(0)) Then
        Me.List2.AddItem (Me.List1.Column(0))
    End If
    To remove items from List2, place this code into OnClick event of the button that would carry out this removal:

    Code:
    If Not IsNull(Me.List2.Column(0)) Then
        Me.List2.RemoveItem (Me.List2.ListIndex)
    End If
    or something like that.....
    If you are using Access97......It gets quite a bit more complicated.


  3. #3
    Join Date
    Dec 2003
    Posts
    26
    I have now included a sample.
    Basicall I want to keep a log of computers at work and when I install a new comptuer I want to select which software is installed. In the example there are three tables
    ComputerTable:
    Name
    Desc

    InstalledSoftware:
    ComputerName (Linked to computer table)
    Softwarename

    SoftwareList
    Softwarename (linked to installed software)

    So individual machine can have different software installed.
    I started using the code above but it wanted me to change the Row Source Type to a value list. which is not what I wanted to do.
    I am trying to copy records
    Attached Files Attached Files

  4. #4
    Join Date
    Dec 2003
    Posts
    26
    Can any one help?

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    I just got done doing this ... What you need is a "Is Visible" column for your selection list ... After each "Add", update the underlying table for the selection to False on the "Is Visible" column and then requery.

  6. #6
    Join Date
    Dec 2003
    Posts
    26
    Sorry mate not sure what you mean any chance you could post some code or edit my small example?

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by teaboy
    Sorry mate not sure what you mean any chance you could post some code or edit my small example?
    I posted the following code on another posting ...

    Code:
    Private Sub RemoveWOButton_Click()
        If AllocList.ItemsSelected.Count < 1 Then Exit Sub
        
        Dim i As Long, ItemCount As Integer, BDRow As Variant, SelArray() As Integer
        
        i = 1
        ItemCount = AllocList.ItemsSelected.Count
        ReDim SelArray(AllocList.ItemsSelected.Count)
        For Each BDRow In AllocList.ItemsSelected
            AllocList.Selected(BDRow) = False
            AvailableQty = AvailableQty + CDbl(AllocList.Column(1, BDRow))
            SQLString = "UPDATE " & WO_Tbl & " SET IsVisible=True WHERE (WorkOrderNumber='" & AllocList.Column(0, BDRow) & "');"
            DoCmd.SetWarnings False
            DoCmd.RunSQL SQLString, False
            SelArray(i) = BDRow
            i = i + 1
        Next BDRow
        AvailQtyLbl.Caption = AvailableQty
        
    '    For i = AllocList.ItemsSelected.Count To 1 Step -1
        For i = ItemCount To 1 Step -1
            SQLString = "DELETE FROM " & AllocListTbl & " WHERE (WorkOrderNumber='" & AllocList.Column(0, SelArray(i)) & "');"
            DoCmd.SetWarnings False
            DoCmd.RunSQL SQLString, False
        Next
        
        AssignToQtyTxt.Value = ""
        WO_ComboBox.Value = ""
        
        WO_ComboBox.Requery
        AllocList.Requery
        AssignToQtyTxt.SetFocus
        EditPerformed = True
    End Sub

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Have you considered using a treeview for this project? I just created the exact same system and it worked really well as a treeview. I tried the listbox thing first but it looked kind of messy.

  9. #9
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Teddy
    Have you considered using a treeview for this project? I just created the exact same system and it worked really well as a treeview. I tried the listbox thing first but it looked kind of messy.
    Thought I'd show you what I setup ...
    Attached Thumbnails Attached Thumbnails my.bmp  

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by M Owen
    Thought I'd show you what I setup ...
    That doesn't look like the same kind of application... This is more what I was talking about..
    Attached Thumbnails Attached Thumbnails myjpg.jpg  

  11. #11
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by Teddy
    That doesn't look like the same kind of application... This is more what I was talking about..
    Mine was more in line with the Access field selector of the Form Wizard ... Yours is definitely more impressive!

  12. #12
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by M Owen
    Mine was more in line with the Access field selector of the Form Wizard ... Yours is definitely more impressive!
    Actually it just looks more impressive. That's kind of what I was getting at. I tried doing that same application with listboxes and it was a nightmare. The treeview simplifies and cleans everything quite nicely. And to be honest.. it requires less skill then the list box version.

    Of course this is all a matter of personal opinion heh.


Posting Permissions

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