• Displaying Multi-Selections in Access97 Form

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Displaying Multi-Selections in Access97 Form

    Author
    Topic
    #351490

    I

    Viewing 0 reply threads
    Author
    Replies
    • #508653

      Are you trying to display selections that were written into a record when that record is current? If so, whether you can or not depends on how you saved the data.

      You’re going to have to provide a lot more information in order to get a useful answer. What is the rowsource for the listbox or boxes? How are the selected items stored? How does the program know which data was originally selected? What does “originally created” mean in this context?

      • #508657

        O.K. Here’s more description of what I’m trying to do.

        On the data entry form the multi-select list boxes are like this:
        Unbound list box Name: lstNames
        Row Source: qryPersonnel (names and unique numbers)

        They appear on a form where an incident is being recorded and the incident has a unique number, which is the link to the list boxes.

        The data is written into a table containing the incident number and the number of each individual involved (tblPersonnelByIncident, containing intIncident and intPersonnel) with an append query. So for each incident there are as many records containing two numbers (incident and person) as there are personnel involved.

        In edit mode, I want the form to appear much as it does in add mode, but with the data filled in, of course. That means the individuals selected in add mode should show as selected when the list box appears. How do I read the records in the table and somehow

        • #508680

          OK, let me make sure I understand. Your listbox is unbound but you want to display the items that have been selected for the record if they open the form again or navigate off that record and then back, is that right? If that’s the case, you could write a function to retrieve the keys for the records that were selected as an array and then in the current event of the form, loop through that array and use it to set the selected property of the items. However, if you have set only the selected property, the listbox won’t reflect those items in the value. You’ll also need code to clear the listbox when the user moves to a new record.

          Multiselect listboxes are input controls, so they aren’t designed to allow easy display. What I usually do is add a textbox or a second listbox and display a concatenated list of values selected in it, kind of like a pick list. But does your form allow them to remove a previously selected employee from the list? That would require still more code to handle. And if they add more selections to that record, you have to decide how you want to handle it.

          • #508683

            O.K. That helps. I like the idea of a second listbox to display the list of values selected. What I had thought of doing for changes was to provide a change button. From that I’d reset the list, delete the records from the table, then get the new list of selections and put them into the table.

            Come to think of it, I’ve seen forms that give the pick list and display the resulting picks in another listbox. That’s an idea that should work here.

            Thanks for your suggestions. If I can work out the code for building and using that array of keys, I think that I can figure out the rest of it.

            Paul

            • #508685

              If you need help with the code, feel free to ask. I just don’t like to post a bunch of code until I’m sure I know what the problem to be solved requires.

    Viewing 0 reply threads
    Reply To: Displaying Multi-Selections in Access97 Form

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: