Thanks for the information.
The relationship between the two tables is a many to one. The many
is the Roster table and the one is the Training table. I also hate
to be redundant
and I wish I knew enough about Access to just use one statement for
many operations. In Dbase or Foxpro you could do that by calling
the procedure. But unfortunately I don't. I'm really a newbe with
about 1months experience.
The reason I need to place a check mark in the training table is
for a future reference. If it can't be done then I'll have to find
a work around.
Thanks for the help
:
Piet's point (in another answer) about redundant data is well made.
However, his solution almost certainly won't work because the
second field
you are trying to update is not in the table which is the form's
recordsource - or at least, from what you've written, I don't
think it is;
I'm assuming that when you say " #1 is active" that you mean that
it is the
recordsource of a form which you are using for data entry/editing.
You don't say what the relationship between your tables is, so it's
difficult to offer any real help. But if you need to do this
(and, as Piet
says, it's likely that you don't), you'll need to create a query
(which must
be updateable (see
http://allenbrowne.com/ser-61.html for more
information);
and if your relationship is a one-to-many one, your query may only
be updateable for fields in one or other table, not both) and use
that as the
recordsource for your form.
A couple of other points:
1. I'm assuming that Trainer is the name of a checkbox control on
your form, and also the name of the field to which it is bound (a
Yes/No field in
table 1). I'd strongly suggest that you give the control a
different name
to its bound field (I'd name it chkTrainer); that way, Access
won't get confused and possibly produce errors.
2. You should not use the Click event of a checkbox to attempt to
change something else when the checkbox changes, since it may not
occur when the control's value changes; eg. if the user tabs to
the control, and changes its state by pressing the space-bar, the
Click event will not occur, and your code will not run. You
should use the AfterUpdate event.
3. If you still decide that you must update a field in a separate
table (and I suggest that you carefully examine you data structure
to ensure that
it's correct - as Piet says, it's likely that you've got redundant
data (or
some other problem)), and you can't construct a suitable updateable
query,
you can instead write some code to run an update query to amend
the data in
the second table.
HTH,
Rob
Afrosheen wrote:
Thanks for reading my question.
I have two tables that I'm working with #1 is Roster, the second
one #2 is Training. They have a relationship. Poor tables. This
is what I'm try to do. #1 is active and when i check a box I want
table #2 to also get the check box. Here is my coding.
Private Sub trainer_Click()
If trainer = True Then <---- Table #1
Me.tbl_training [check] = True <-----Table #2
Else
Me.tbl_training [check] = False
End If
End Sub
I keep getting an error. I thought I was putting the code in
correctly. I must be suffering from dain bramage.
Your help would be appreciated.
Thanks