Mervyn:
As well as inserting new rows via a subform as the others have described
you
can also insert rows on the basis of the data in your current table with
three append queries. What you do is join the current People table to
the
Groups table on one of the three existing three group fields, then append
the
PersonID from the People table and the GroupID from the Groups table into
the
new PersonGroup table, so the first append query would be like this:
INSERT INTO PersonGroup(PersonID, GroupID)
SELECT PersonID, GroupID
FROM People INNER JOIN Groups
ON People.FirstGroupField = Groups.Group
WHERE People.FirstGroupField IS NOT NULL;
then:
INSERT INTO PersonGroup(PersonID, GroupID)
SELECT PersonID, GroupID
FROM People INNER JOIN Groups
ON People.SecondGroupField = Groups.Group
WHERE People.SecondGroupField IS NOT NULL;
and finally:
INSERT INTO PersonGroup(PersonID, GroupID)
SELECT PersonID, GroupID
FROM People INNER JOIN Groups
ON People.ThirdGroupField = Groups.Group
WHERE People.ThirdGroupField IS NOT NULL;
Once you are happy that the rows have been correctly inserted into the
PersonGroup table you can delete the redundant FirstGroupField,
SecondGroupField and ThirdGroupField fields from the People table.
One other thing you should do if you have not done so already is create a
unique index on the PersonID and GroupID columns (fields) in the
PersonGroup
table. This will prevent duplicate rows being inadvertently entered.
The
easiest way of doing this is by making the two columns the table's
composite
primary key, which you do in table design view by Ctrl-clicking on each
field,
making sure you click on the field selector (the little grey rectangle to
the
left of the field name), then right-click and select 'Primary key' from
the
shortcut menu.
If you are already using another column as the primary key you can index
the
fields uniquely by selecting indexes from the View menu. Enter a
suitable
index name in one row of the left column, then enter the column names on
two
rows of the Field Name column. With the first row (the one with the
index
name) selected enter Yes as the 'Unique' property. If you are using
Access
2007 the interface for doing this will differ, but should essentially be
the
same,
Ken Sheridan
Stafford, England
Mervyn said:
Rob - Many thanks - can you help me a bit further? I formed a table
as
suggested and did joins to the other tables but how do you actually
produce
the records in this new table? _ I'm absolutely new to all this !
Apologies !
Mervyn
Hi Mervyn,
[quoted text clipped - 21 lines]
how do you do a report which shows who is in group1, group2,etc ?
Sorry it seems a simple question but it has me stumped!