What do you mean by "and the subform should have a combo box bound to
PostActivityID, itself based on the Activity table." I have a combobox with
control source PostActivityID, what do you mean by based on activity table?
And I intend on having just having the one Activity2PostActivity table that
will be used for two different forms. One to assign pre-activities and one
for post-activities. Both forms will write to the same table and should
update when changed. So when I assign Activity2 as a post activity for
Activity1, Activity2 should now update with Activity1 as a pre-activity.
Ok... that makes sense. What's the *ROW SOURCE* of the combo box? A combo gets
its data from the Row Source (usually a query) and stores the bound column of
the selected record in its Control Source field.
So the error that I am getting when selecting a post activity in the
subform: "The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key, or
relationship. Change the data in the field or fields that contain the
duplicate data, romve the index, or redefine the index to permit duplicate
entries and try again"
What's the Primary Key of Activity2PostActivity? It sounds like it's
PostActivityID; if so, that's the source of the problem. It should be a joint
two-field key comprising ActvityID and PostActivityID, so that a single
activity can have one or more pre- or post-activities, and each activity can
serve as a pre- or post-activity multiple times.
So the subform should be getting the ActivityID from the main form and the
ActivityID of the activites selected. How do I specify that I want the
ActivityID of the selected activity to be entered as the PostActivityID? I
think this may be where I'm having problems.
The ActivityToPostActivity table should (I'd think, I can't see your database)
have three fields:
ActivityID Long Integer link to Activities.ActivityID
AssociatedActivityID Long Integer link to Activities.ActivityID
PrePost Integer, with 1 meaning that this is a preactivity, 2 a postactivity
The Primary Key of this table should consist of BOTH ActivityID and
AssociatedActivityID; ctrl-click both fields in table design view and select
the key icon.
This will let you store both pre and post activities in the same table. If you
want to use two subforms (which is probably good for your users!) then base
one subform on a Query with 1 as a criterion on PrePost, and the other on a
query using 2.
John W. Vinson [MVP]