Complex automated populated subform

Tiger955

Registered User.
Local time
Today, 14:40
Joined
Sep 13, 2013
Messages
140
Hi,

I have a difficult problem to solve.
Here is the description of the problem:

A certain number of teams of employees, which per default have to include a variable number of female and male members per team and each team should be filled automatically from a table of employees showing name and gender.

It would beneasy to loop through all teams from 1 to x and populate them, but if so, the first teams would be filled up and the later teams or the last teams would be empty maybe.

So this routine should populate the teams per random, considering the gender needed.

The teams could include allready some members too, meaning that for example
in team1, where the total of members should be 10, there are already 3 members, one female, two male. So team1 needs more 1 female and 6 male members to be complete. And so on.

Additionaly the total of possible members from table employees is less than the sum of all members needed jn all teams.

Example:
Team1 needs 2 female, 8 male, still no members
team2 needs 1 f, 12 m, 1 f plus 4 m already assigned
Team3 needs 8 m, 5 m already asigned.
Etc.
Total all teams 30 female, 70 male, 10 f plus 20 m already assigned.
Table employees has only 80 persons.

At the end each team should include about the same number of employees paying attention the required gender and the number of members which have been allready assigned before filling up the teams.

I hope to have described the problem to be understandable and I can get some help how to solve it.

Michael
 
Hi Michael, a funny little puzzle you have got here.
I've made a small solution for you, in the attached database, (there are place for some improvement, but I'll leave it for you to do that).
Open the only form in it at click the button.
Then open the query "BetweenStatus", which shows the created teams.
The code behind the button do have some comments, else ask.
 

Attachments

Last edited:
Hi JHB,
Thanks a lot for your fast reply.

I will test it until thuesday with my database and reply then.

Just had an overview on your code. Why do you delete the tmp needed tbls and then create them again and not just delete the records in those tbls?
Is there any special idea behind?

Thanks again
Michael
 
Hi JHB,
Thanks a lot for your fast reply.

I will test it until thuesday with my database and reply then.

Just had an overview on your code. Why do you delete the tmp needed tbls and then create them again and not just delete the records in those tbls?
Is there any special idea behind?

Thanks again
Michael
Normally I delete the table after I've used them to get rid of them and it is in some cases faster as empty them.
 
Hi JHB,
Thanks a lot for your fast reply.

I will test it until thuesday with my database and reply then.

Just had an overview on your code. Why do you delete the tmp needed tbls and then create them again and not just delete the records in those tbls?
Is there any special idea behind?

Thanks again
Michael
 

Users who are viewing this thread

Back
Top Bottom