Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    11

    Unanswered: multi-select list boxes

    I have a list box created with the multi select property set at simple. If I select 3 items, I can't get it to capture more than one of the selected items. It is only capturing the first of the 3 that is selected. What do I need to do to get it to caputure the rest. I have a total of 12 items in the list and I have no Visual Basic Programming background.

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Without knowing VB I am not sure how to explain it. Maybe if you give more details about what you are trying to do someone can write some code for you. Include the name of the listbox and what you want to do with the 3 selections. (Print a report, save in a table, etc.)

  3. #3
    Join Date
    Jul 2003
    Posts
    81

    Thumbs up Re: multi-select list boxes

    Use the properties of the List Box control and set the Multi Select property to Extended. Now you can use the Ctrl or the Shift to pick records from the list.

  4. #4
    Join Date
    Apr 2004
    Posts
    11

    list box

    Originally posted by DCKunkle
    Without knowing VB I am not sure how to explain it. Maybe if you give more details about what you are trying to do someone can write some code for you. Include the name of the listbox and what you want to do with the 3 selections. (Print a report, save in a table, etc.)
    I have am trying to get them to select any of the following or more than one if necessary to the question and the choices end up in the table. When I test the form, I can choose as many of the fields as I want but nothing goes back into the table. The question is as follows:
    How did you find out about our company?
    The choices are:
    Friend, Family, Advertisement, Bus Tour, Local Resident, Been Here Before, Walk-In, Drive By, Nascar, Harness, Vacation, Other

    The choices are to go back to a field in the main table called SurveyTable1. The field name is the title of the question.

  5. #5
    Join Date
    Jul 2003
    Posts
    81

    Re: list box

    OK

    I'm using this code to a project. Try it using your controls. The things you cannot read are in greek. It is Only a message in greek, don't use it

    Private Sub cmdPinakas_Click()
    Dim rsttblPinakas As New ADODB.Recordset
    Dim intCurrEmployee As Integer
    Dim varEmployee As Variant
    Dim strChoose As String

    strChoose = MsgBox("Να διαγράψω την προηγούμενη λίστα;" & Chr(13) _
    & "Επιλέξτε Νο για να προσθέσετε υπάλληλο στη λίστα.", vbYesNo + vbQuestion, "Ερώτηση")

    If strChoose = vbYes Then

    '-- Delete the previous choices from the table
    CurrentDb.Execute "Delete * From tblPinakas"

    '-- Open the tblPinakas table
    rsttblPinakas.Open "tblPinakas", _
    CurrentProject.Connection, adOpenKeyset, _
    adLockOptimistic, adCmdTable

    '-- For each of the items in the ItemsSelected collection
    '-- Add a new record in the TablesChosen table.

    For Each varEmployee In Me!lboEmployeeToChoose.ItemsSelected

    rsttblPinakas.AddNew

    rsttblPinakas.Fields("FirstName") = Me.lboEmployeeToChoose.Column(0, varEmployee)
    rsttblPinakas.Fields("LastName") = Me.lboEmployeeToChoose.Column(1, varEmployee)
    rsttblPinakas.Fields("Sector") = Me.lboEmployeeToChoose.Column(2, varEmployee)
    rsttblPinakas.Fields("DateHire") = Me.lboEmployeeToChoose.Column(3, varEmployee)
    rsttblPinakas.Fields("Father") = Me.lboEmployeeToChoose.Column(4, varEmployee)
    rsttblPinakas.Fields("Mother") = Me.lboEmployeeToChoose.Column(5, varEmployee)
    rsttblPinakas.Fields("Age") = Me.lboEmployeeToChoose.Column(6, varEmployee)
    rsttblPinakas.Fields("Children") = Me.lboEmployeeToChoose.Column(7, varEmployee)
    rsttblPinakas.Fields("KPOAED") = Me.lboEmployeeToChoose.Column(8, varEmployee)
    rsttblPinakas.Fields("IKA") = Me.lboEmployeeToChoose.Column(9, varEmployee)
    rsttblPinakas.Fields("DatesOfWork") = Me.lboEmployeeToChoose.Column(10, varEmployee)
    rsttblPinakas.Fields("Money") = Me.lboEmployeeToChoose.Column(11, varEmployee)
    rsttblPinakas.Fields("MarriedID") = Me.lboEmployeeToChoose.Column(12, varEmployee)
    rsttblPinakas.Fields("Print") = Me.lboEmployeeToChoose.Column(13, varEmployee)



    'Me!lboEmployeeToChoose.ItemData(varEmployee)

    rsttblPinakas.Update

    Next varEmployee

    rsttblPinakas.Close

    DoCmd.OpenReport "rptPinakas", acViewPreview

    Else
    '-- Open the tblChosen table
    rsttblPinakas.Open "tblPinakas", _
    CurrentProject.Connection, adOpenKeyset, _
    adLockOptimistic, adCmdTable

    '-- For each of the items in the ItemsSelected collection
    '-- Add a new record in the TablesChosen table.

    For Each varEmployee In Me!lboEmployeeToChoose.ItemsSelected

    rsttblPinakas.AddNew

    rsttblPinakas.Fields("FirstName") = Me.lboEmployeeToChoose.Column(0, varEmployee)
    rsttblPinakas.Fields("LastName") = Me.lboEmployeeToChoose.Column(1, varEmployee)
    rsttblPinakas.Fields("Sector") = Me.lboEmployeeToChoose.Column(2, varEmployee)
    rsttblPinakas.Fields("DateHire") = Me.lboEmployeeToChoose.Column(3, varEmployee)
    rsttblPinakas.Fields("Father") = Me.lboEmployeeToChoose.Column(4, varEmployee)
    rsttblPinakas.Fields("Mother") = Me.lboEmployeeToChoose.Column(5, varEmployee)
    rsttblPinakas.Fields("Age") = Me.lboEmployeeToChoose.Column(6, varEmployee)
    rsttblPinakas.Fields("Children") = Me.lboEmployeeToChoose.Column(7, varEmployee)
    rsttblPinakas.Fields("KPOAED") = Me.lboEmployeeToChoose.Column(8, varEmployee)
    rsttblPinakas.Fields("IKA") = Me.lboEmployeeToChoose.Column(9, varEmployee)
    rsttblPinakas.Fields("DatesOfWork") = Me.lboEmployeeToChoose.Column(10, varEmployee)
    rsttblPinakas.Fields("Money") = Me.lboEmployeeToChoose.Column(11, varEmployee)
    rsttblPinakas.Fields("MarriedID") = Me.lboEmployeeToChoose.Column(12, varEmployee)
    rsttblPinakas.Fields("Print") = Me.lboEmployeeToChoose.Column(13, varEmployee)



    'Me!lboEmployeeToChoose.ItemData(varEmployee)

    rsttblPinakas.Update

    Next varEmployee

    rsttblPinakas.Close

    DoCmd.OpenReport "rptPinakas", acViewPreview
    End If



    DoCmd.OpenReport "rptSimvasi4h", acViewPreview
    If Reports!rptSimvasi4h.Report.HasData = 0 Then
    DoCmd.Close
    End If

    End Sub

Posting Permissions

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