Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Dec 2000
    Location
    Nebraska
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying Multi-Selections in Access97 Form

    I

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Displaying Multi-Selections in Access97 Form

    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?
    Charlotte

  3. #3
    Lounger
    Join Date
    Dec 2000
    Location
    Nebraska
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Displaying Multi-Selections in Access97 Form

    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

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Displaying Multi-Selections in Access97 Form

    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.
    Charlotte

  5. #5
    Lounger
    Join Date
    Dec 2000
    Location
    Nebraska
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Displaying Multi-Selections in Access97 Form

    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

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Displaying Multi-Selections in Access97 Form

    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.
    Charlotte

Posting Permissions

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