Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2011
    Location
    Chicago
    Posts
    37

    Question Unanswered: Need help with listboxes

    I'm building an Access 2007 DB for work, a very simple one, but I haven't used access since 2000 (its safe to say I'm very rusty). The DB will store employee resume info i.e. name, school, degree, grad year, and skills. I have the skills options listed in a listbox and want to create a button/command to move the skills to another skills box (such as select and individual skill or select all). I'm unfamilar with code and/or macros so any help would be greatly appreciated.

  2. #2
    Join Date
    Jul 2011
    Posts
    63
    I have a solution for transfering combobox to list. This however, doesn't prevent duplicates and I'm still trying to find a solution.

    Private Sub btnAddSkill_Click()
    lstSkills.AddItem Item:=Me.cboSkill1.Value
    End Sub

    Here's a neat link that might help.
    Amazing things you can do with the Listbox control | Visual Basic 6 (VB6)

  3. #3
    Join Date
    Jul 2011
    Location
    Chicago
    Posts
    37

    cool

    Quote Originally Posted by tkepongo View Post
    I have a solution for transfering combobox to list. This however, doesn't prevent duplicates and I'm still trying to find a solution.

    Private Sub btnAddSkill_Click()
    lstSkills.AddItem Item:=Me.cboSkill1.Value
    End Sub

    Here's a neat link that might help.
    Amazing things you can do with the Listbox control | Visual Basic 6 (VB6)
    Thanks. I'll try that code and also look at the link you sent. Appreciate your reply on this.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can always check the existing values before adding a new one but the could be a little slow. Personally I would have the values stored into a table that would be the list Recordsource and have a Unique index defined into that table. For adding a value into the list I would add the value into the table, then requery the list.
    Have a nice day!

  5. #5
    Join Date
    Jul 2011
    Location
    Chicago
    Posts
    37

    thanks

    I'll definitely try that as well if the first suggestion doesn't work. I appreciate your input.

  6. #6
    Join Date
    Jul 2011
    Location
    Chicago
    Posts
    37
    Quote Originally Posted by Sinndho View Post
    You can always check the existing values before adding a new one but the could be a little slow. Personally I would have the values stored into a table that would be the list Recordsource and have a Unique index defined into that table. For adding a value into the list I would add the value into the table, then requery the list.
    How would I do this exactly? Again I'm very noobish when it comes to building DB's, same with Access.

  7. #7
    Join Date
    Jul 2011
    Posts
    63
    Try this

    Code:
    lstAuditors.AddItem Me.cboAuditors.Column(0) & ";" & Me.cboAuditors.Column(1)
    Dim item As Variant
        For i = 0 To lstAuditors.ListCount - 1
            item = lstAuditors.ItemData(i)
            For j = i + 1 To lstAuditors.ListCount - 1
                If item = lstAuditors.ItemData(j) Then
                    lstAuditors.RemoveItem j
                    MsgBox "Error: Cannot Add Duplicate Auditor"
                    Exit For
                End If
            Next
        Next

Posting Permissions

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