Create multiple records in subform and pre-populate each record

M

Maverick

I have a subform that tracks multiple activities for each objective. However,
one of my objectives always has the same three activities. What I want to do
is, from the click of a checkbox (with the value = True), create the record
for activity 1 and put specific text in the activity field, create a record
for activity 2 and put specific text in the activity field, and the same for
activity 3.

Of course, I need to make sure that no activities already exist for this
objective before it performs this action. If activities exist in the subform,
then the code would eliminate (or append) the current records and replace
with the three specific activities.

I'd also like to be able to delete the three records if the checkbox = False.

Main form: frmObjectives
Subform: sfrmActivities
Linked Child field: ObjectiveID
Field to populate on subform: Activities
Checkbox to trigger code (via On Click event): chkMethodsUsed

Thank you.
 
M

Maverick

Comments/questions inline..... Thank you.

Steve Sanford said:
Hi Maverick,

Comments/questions inline.....



How do you identify the objective? Is there a text field or a PK from a
table? If it is a string, what is the exact text of the objective?
What is the name of the control on the main form that has the objective text?

The objective is identified by the autonumber PK named ID in tblObjective
and FK named ObjectiveID on the subform. The control on the main form that
has the objective text is named Objective.
What is the "specific text" for each of the 3 activities you want to add?

The text isn't important here. It is merely 3 different text strings
identifying different activities. One text string for each record. They are
as follows:

** Each staff person must have the following as an objective and the weight
may be 10-40%.

Successfully complete performance objectives in a manner consistent with the
behaviors demonstrated in the "Methods Used to Achieve Results" section of
this appraisal form.

See Section III
The bottom line contradicts the previous paragraph.
Do you want to delete ALL records in the subform for the specific objective
or just the three activities??

They aren't contradictory. What I want to do is have the code look at the
activities for the objective. If the checkbox = True then the three activity
records should be the three text strings predefined above. If the checkbox =
False, then all activities for this objective (specifically these three
activities) should be deleted.
I am guessing that "chkMethodsUsed" is on the main form??

Yes, it is on the main form.
What are the names of the two tables that holds the records for the main
form and the sub form records?

Table for main form: tblObjectives
Table for sub form: tblActivities
 
S

Steve Sanford

I have most of the code to completed, but I need a little more.... :)
The objective is identified by the autonumber PK named ID in tblObjective
and FK named ObjectiveID on the subform. The control on the main form that
has the objective text is named Objective.

If I am looking at a list of objectives on the main form, what identifies
the specific objective that should have the three records inserted
into/deleted from the activities table? Is there text in the control bound to
the field [Objective] that would tell you that there should be records with
the text strings you provided?
 
M

Maverick

That is the purpose of the checkbox. If the checkbox = True, then the three
activities need to exist and if it = False, then those three activities
shouldn't exist.

There is only one objective on the main form. Each record holds a single
objective and the subform has the activities for that one objective.

Hope this helps.

Steve Sanford said:
I have most of the code to completed, but I need a little more.... :)
The objective is identified by the autonumber PK named ID in tblObjective
and FK named ObjectiveID on the subform. The control on the main form that
has the objective text is named Objective.

If I am looking at a list of objectives on the main form, what identifies
the specific objective that should have the three records inserted
into/deleted from the activities table? Is there text in the control bound to
the field [Objective] that would tell you that there should be records with
the text strings you provided?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top