Well, it makes sense, but I was hoping for more details
about the situation you are trying to deal with.
What does it take to be a trainer?
What fields are in the Trainers table?
Somehow I have the impression that the Trainers table only
has one field for the trainer's name. ** IF ** a person
becomes a trainer if, and only if, all four yes/no fields
are true, then you can just set the combo box's RowSource to
a query something like:
SELECT [employee name field]
FROM [employees table]
WHERE [check1 field] And [check2 field]
And [check3 field] And [check4 field]
ORDER BY [employee name field]
Then the list will be up to date every time the form is
opened, without any code.
If my guesses are incorrect, please explain what the real
situation is all about (instead of telling me what your form
is, or is not, doing).
--
Marsh
MVP [MS Access]
I have designed this database for other users to fill in. If they check all
four squares, the employee is 100% and that is when I wanted the employee
name filled in as a trainer. The code I included does work, but the user has
to fill in the employee name in the "Trainer" combo box instead of having
Access automatically add the name without asking "Do you want to add this
employee as a trainer". Hope that makes more sense?
Marshall Barton said:
Michelle wrote:
Marsh, I hate to get greedy, but now that the code is working I would like to
expand on it. Right now the user can enter a new "Trainer Name" when a
certain criteria is met. I would actually like the "Trainer Name" added
automatically when a certain criteria is met.
When an employee reaches 100% (which is noted in the "Flexibility %" text
box) is there a way their name can be added automatically to the "Trainer
Name" combo box. My code right now is...
Private Sub Trainer_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
If MsgBox("Do you wish to add this employee as a Trainer?", vbYesNo) = vbYes
Then
db.Execute "INSERT INTO [Trainer Names]([Trainer Name]) VALUES (""" &
NewData & """)", dbFailOnError
Response = acDataErrAdded
Else
Me.Trainer.Undo
Response = acDataErrContinue
End If
End Sub
and it works great, asking the user if they would like to add the employee.
I don't understand. If you want to add the 100% names to
the combo box list, why not just include those names in the
combo box's RowSource query?
I'm probably missing something important there. Here's
another thought, how about adding the name to the trainers
table in the form's AfterUpdate event?
If the 100% criteria is required and the only field in the
trainers table is the trainer name field, then I don't see a
need for the trainer names table.
It seems that I need a lot more detailed information before
I can make a meaningful suggestion about this aspect of your
situation.