Selecting items from the list of a combo-box.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how to select items from a combo box using a loop? There is
only one combo box on a subform, and I need your help to allow the user to
have the program select Item0 on Subrecord1, Item 1 on Sebrecord2, and so on.

Thanks in advance,
James
 
James

It would help if you described an example of the data and why the user needs
to select different parts on different subrecords. What do you mean by
"Item0", "Item1", ...?
 
This is for a scheduling system, and I don't want the user to have to select
every position from a drop-down list.

On the subform there are two combo boxes. The first combo box is the one
mentioned above with all of the positions. Once a position is selected from
cboPosition, the user has to assign an employee to that position using the
2nd dropdown box (cboEmployee). That is done until the user has all, or
some, of the positions filled.

Right know the user has to do redundant work by selecting over and over the
positions and employees. I would like to write a program that will selects
the position and assign an employee automatically for as many time as there
are positions.

1 position = 1 record, and all of the positions are linked to the parent
records ID.


Thanks ,
James
 
James

I am still not clear on what data you are working with, as your description
seemed to focus more on the forms you are using.

Are you saying you have Positions and Employees, and they are in a
many-to-many relationship?

I don't understand why you'd want to (?randomly?) assign Employees to
Positions "as many times as there are positions". Can you give a real-world
example?
 
Thanks again!

Basically, instead of a manager going through and writing a schedule one
position by one (assigning an employee to a possition, eg...john is a server
on 1/1/01; steve is a busser on 1/1/01; and so on.) why can't the computer do
this by "systematichaly" selecting employees to fill the position.

Anyways...I have been able to make it assign the values as I was hoping to,
but since it is on a subform I can't get it to go to the next record on the
subform. When I use docmd.GoToRecord AcNext it move the parent record ahead,
not the subform record.

Do you know how to move through subform records?

James
 
James

If you are going to do this in code, you don't need the combo box or the
subform. Instead, you just need to know how you get the recordsets you use
in these. The combobox has a RowSource property. The subform is just a
form, and has a source property as well.

If you haven't done any VBA programming before, the learning curve on this
may be a bit steep.

Generically, what you'd do is:

* Get the recordset of (open) Positions
* Start at the first one
* Get the recordset of (available) Employees
* Start at the first one
* Assign the first Employee to the first Position
* Check for any remaining "openings" for that Position (i.e., what's the
total count of open Positions of that type?) -- if you have any left "open",
go to the next Employee and go back one.
* If you don't have any more open Positions of this type, go back up and
get the next Position
* You'll need to get the recordset of Employees again, since one (or more)
has already been assigned
 
Back
Top