Using subform to add new records

S

stuartf

This is probably bread and butter stuff but I can't work out how to d
it!

I have data stored in 2 tables.
One is a list of groups and has fields GroupNumber, LeaderID, DeputyID
The other table holds the data for where these groups are at any time
It has fields GroupNumber, Time, Activity, Location.

In the first table GroupNumber is the primary key, in the secon
GroupNumber and Time are a composite key.

What I want to be able to do is to create a form that has GroupNumbe
at the top and a subform on it that lists only Time, activity an
location. I created a subform as a datasheet that takes data from th
activity table and a main form that takes GroupNumber from the grou
table when i link these using GroupNumber in the master and chil
fields and try and cycle through all the group numbers I get record
for each and everyinstance of the GroupNumber and Time pair.

I've just re-read what I've written and it doesn't make sense even t
me so here's an example of what I'm trying to achieve. I'm not 100
sure of the right terms to use to explain it to you :(

I have data like:


Code
-------------------

Group# LeaderID DeputyID
1 1 2
2 3 4

Group# Time Activity Location
1 0800 registration room 22
1 0900 coffee main hall
2 0800 registration room 19
2 1015 lecture main hall

-------------------


I want my form to look a bit like this:


Code
-------------------

Group# 1

Time Activity Location
0800 registration room 22
0900 coffee main hall

-------------------


where the time, activity and location will allow additions tha
automatically fill in group# using the one at the top of the page
Ideally I should be able to type any group number in to the top box an
go direct to that group's list and make edits and additions to th
subform rather than having to cycle through as there will be ~10
groups.

I can do it using an unbound box as group# and rerunning a query usin
the onUpdateEvent to filter only the data I want to see but that onl
allows edits of the existing records and doesn't allow me additions a
the group# remains 0 (the default value for all new records i try an
add. Besides it's a bit of a crude hack. There must be a proper way t
do this.

That should be easy shouldn't it??
Why am I totally unable to make it work!

All help gratefully received
 
J

Joan Wild

I have data stored in 2 tables.
One is a list of groups and has fields GroupNumber, LeaderID, DeputyID
The other table holds the data for where these groups are at any time.
It has fields GroupNumber, Time, Activity, Location.
I've just re-read what I've written and it doesn't make sense even to
me so here's an example of what I'm trying to achieve. I'm not 100%
sure of the right terms to use to explain it to you :(

I understood you. Create a relationship in the relationship window from
GroupNumber in the Group table to GroupNumber in the Activity table and
enforce referential integrity.

Then you will find that the Form wizard will create the form you want
easily. Choose create form by using wizard. At the very first step choose
your Group table and the GroupNumber field. Before clicking next, choose
your Activity table and the fields you want to appear. When you click next,
you'll see that the wizard will automatically assume you want a main form/
subform setup.

Hope that helps.
 
Top