First, if you are using a access ADP project, then you do in fact have
triggers, and have stored procedures run when you update a table. (ADP
projects have been available for the last 3 versions of ms-access, and with
them you can use triggers.
However, if you are not using a adp project, then just use the forms after
update event, and you can add the child record.
I have two tables, volunteers and volunteeractions. The user interacts with
them via forms. I want to create a record in volunteer actions whenever a
new record is created by a form based on Volunteers table.
I don't think you actually need, or want to create a actions record when you
add a volunteer. I would think that you WAIT until the user actually needs
to enter some actions data. It sounds silly to have action records strewn
all over the place until you actually need to do this. All reports and
queries can still return volunteers and joined actions, and volunteers will
STILL appear in reports even when there is no child records (assuming you
want to them to appear, and assuming you set your queries as left joins.
Note that about 90% or more of your quires will in fact be left join).
I am only pointing the above out, since 9 out of 10 times, people want to
create a child record to solve the join problem, and not the fact that they
need an actual child record. You should only add the child record WHEN data
needs to be entered for the child record (in your case the actions table). I
could also be very wrong in your requirements also, but I just wanted to
point the above out, and try to save you some pain. I guess I am saying that
you don't want to add a actions record until you actually reach the time
where you (your users) are going to enter some information into this actions
record. To add the record before it is needed tends to result in a record
that is incomplete, and often not needed. Further, reports that do counts of
active actions, and other forms/reports that retrieve the "last" action
record are going to be rather messy in this case, since you will as a
general rule have un-competed records all over the place.
Whenever a volunteer action record is marked as completed I want to
auto,matically create the next action record based on a predetermined
sequence of actions.
How, or when do you mark a action record as completed? (perhaps, you just
check a box? Why not add the code to the check box after update event?.
Further, you will have some issues as to this being a new record, or a old
record being edited, and in that case, you do might want to add another
child record, do you? So, you do open up a few issues here to deal with if
you are auto add this record.
And, you might want to note that just allowing the user to navigate on the
sub-form will auto create the record IF the user types something into the
record. As a normal approach, the one to many, and the adding of child
records in ms-access is done with a sub-form, and it is automatic affair.
When you actually start typing in a sub-form record, you will notice that
*instantly* right below the record when using a continues form, that a new
space/blank record appears for you automatically to enter additional
information (but, that reocrd is NOT added untill you actually type into
it).
Is there a similar
mechanism available in Access?
As mentioned, in a ADP project, you do have table triggers.
However, with forms, just use the controls after update event, or use the
forms after update event if you want to operate on a record level. This
essentially gives you the same function as a trigger.
Since mere navigation in a sub-form will automatically create the action
record, you might be conceptually approaching this solution in the wrong
way. When you come form VB to ms-access, then a mind set change has to
occur. And, when you come from FoxPro to ms-access, then again what was
standard fair and was a normal approach in Fox has to be changed. And, if
you come from oracle, then again, a conceptual change has to occur. And, to
be fair, the reverse is also true. In other words, the conceptual designs
and approaches use will change for the given tool you use.
Much of what you seem to be asking occurs rather naturally when you work
with the way that ms-access works.
It is also not clear if you are using a sub-form arrangement here to add
those actions recodes or not. I talk about sub-forms here:
http://www.members.shaw.ca/AlbertKallal/Articles/fog0000000005.html