Link to home
Start Free TrialLog in
Avatar of JayABee
JayABee

asked on

Access 2003: Multiselect Listbox - saving and restoring

Database created to enter workplan for the Section, which has tables for Staff, Team, Objectives and Activities. Each objective has one or more related activities, and each staff member belongs to only one team. There is an objective form and activities sub-form.

Each activity may have one person, multiple people (same or different teams), an entire team or multiple teams working on it. As such, I added a listbox which is populated by a query which unions the staff and team tables to provide a list of all staff and teams. My desired outcome is twofold:

1) Make selection(s) from the listbox and save to a table (or field?);
2) Be able to reflect the selections when the forms are being browsed.

I have not created the table (or field?) to house the listbox selections yet, since I'm not sure what I'll be saving to it. I will also be generating reports, but I'm hopeful that if the right data is saved this should not be too traumatic.

Hope this isn't too long and I am clear. Any assistance that can be provided will be greatly appreciated!
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

This could be a difficult relationship to illustrate, depending on what you other requirements would be.

You have an Item (an Activity, in this case) which can be related to two different entities (Staff and Team). That Item can be related to multiple numbers/combinations of those Entities.

Your Union query should bring together the needed items for a listing ... I'd suggest, however, that you represent with a subform (which can be constructed to look very similar to a listbox, if need be) which could then relate the user choices of Staff + Team with an Activity. Access would then handle both your #1 and #2 questions for you, assuming (a) you setup this table relationship properly and (b) you setup the mainform/subform properly.

Same would apply for reporting ... you'd use a report/subreport setup to display the Activity + (Staff and/or Team) relationship.
I take it persons and teams is mutually exclusive.  You have either individual(s) selected or team(s) selected??

You cannot have one or more persons plus one or more teams to which the persons do not belong??
Avatar of JayABee
JayABee

ASKER

GRayL...that's correct.  If a team is selected then the indivual members of the team would not be, and if an individual is selected, the team that person belongs to would not be.

LSMConsulting...not sure I know how to do your (a) and (b) suggestions to make it work.
How will you relate an Activity to a Staff member and/or a Team? You must represent this via a table, and typically you'd have a Join table to do this, but how would you differentiate between a Staff member and a Team?

Perhaps you would need two tables for this relationship - one to store an Activity + Team, and another to store Activity + Staff:

tActivity
-------------------
lActivityID [PK, Autonumber]
sActivityDesc
dActivityDate
etc etc

tStaff
----------------
lStaffID [PK, AN]
sLastName
sFirstName
etc etc

tTeam
--------------
lTeamID
sTeamName
etc etc

tTeamMembers
---------------
lTeamMemberID [PK]
lTeamID
lStaffID

Using this setup, you can add Staff, then add Teams, then add Staff to Teams, then add Activities. Now, to relate both:

tActivityTeams
--------------------
lActTeamID
lActID
lTeamID

And to add Staff to Activity

tActivityStaff
------------------
lActStaffID
lActID
lStaffID

tActivityTeam would store the link between an Activity and a Team, which is (of course) made up of various Staff members. tActivityStaff would store the link between an Activity and an individual Staff member.

I'm not sure how you'd represent this on a single form ... it would seem to me the simplest way would be to use 2 subforms, one based on each of the Activity join tables above. You can build a subform to look very similar to a listbox, and if you use a subform you can allow Access to keep up with the data storage.

Of course, you would need code in both to insure that a user has not already been selected when trying to add that user via Staff or Team. You'd do this in the BeforeUpdate event of those forms.
Avatar of JayABee

ASKER

Will give a try and see...many thanks for your efforts!
scott:  You seem to have misplaced Objectives ;-)
ASKER CERTIFIED SOLUTION
Avatar of GRayL
GRayL
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayABee

ASKER

Each team leader inputs the work plan objectives for the year (agreed upon with senior management) and any related activities in which the entire team is involved.  Each staff member then adds the specific activities under each objective which relate to them, or which they are working on jointly with others (having agreed who will enter which joint activity to avoid redundancy; I plan on working out a more elegant solution, time permitting).  There is a main objective form and an activities sub-form.   The initial design had each activity with only one accountable staff member, now it requires all involved staff members/teams to be reflected in each activity.

So where a combo box worked quite nicely to pick one staff member, I was considering a listbox to select multiple staff members/teams.
As you can see from my code above,  making one or more selections in either box renders the other box locked.  It is impossible to get a mixture from both boxes -  one or more Staff or one or more Teams.  
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayABee

ASKER

Thanks Scott...will work on this today and see how it goes.

GRayL: I also like the idea of two multiselect boxes for staff and teams.
IMHO, it's the only way you can provide the option of selecting one or the other, but once made, freezing out the other until you have completely 'backed out' of the selected list box.