Add Record - populate Field from Main Form

joepineapples

Registered User.
Local time
Today, 10:47
Joined
Apr 28, 2006
Messages
29
I feel like I'm being a bit thick here - hopefully this is the case and this is easy to do.

I have a Subform that is linked to a Mainform by a unique key field [FinanceCode]. The sub form shows all the records that are linked.

What I want is to, when I click on the create rew record button, is add a new record that populates the linked subform field [FinanceCode] with the [FinanceCode] from the Mainform automatically.

How would I go about this?
 
I feel like I'm being a bit thick here - hopefully this is the case and this is easy to do.
It comes to us all.

I have a Subform that is linked to a Mainform by a unique key field [FinanceCode]. The sub form shows all the records that are linked.

What I want is to, when I click on the create rew record button, is add a new record that populates the linked subform field [FinanceCode] with the [FinanceCode] from the Mainform automatically.

How would I go about this?

Provided you have set up the relationships correctly then this should be done automatically by Access.

Without opening any tables, queries, forms or etc, i.e: with just the, for want of a better description, "database components navigator window" open (i.e: the one that lists the tables, etc depending on what you've clicked on) you should see on the tool bar along the top an icon with what looks like three 'windows' on it. If you hover the mouse over the icons you should be able to determine which one is for 'relationships'.

Open the relationships and ensure that both the main- and sub-tables have been added to the view. Next drag the FinanceCode attribute of the main table across to the FinanceCode attribute of the sub-table. Once completed there should be a line connecting the two, hopefully with an infinity sign (a figure 8 turned over on its side) at the sub-table end and a '1' at the main table end.

The inifinity sign indicates that there could be multiple entries in the sub-table against one entry in the main-table, in other words this is a many-to-one, or m:1, relationship.

HTH

Tim
 
Thanks Tim

Sometimes I try and charge in forgetting about the basics!

The tables that feed the sub form and main form are now linked together so the sub form shows all the correct info. (I didn't get the figure 8 though - I'm using access 97 - so I'm guessing that's not a feature it has?)

It didn't automatically add the Key field when I added a new record though. I've set the field default in the sub form to be the same as the primary key in the main form through the field properties.

This one has been bugging me for a while ... glad it's now resolved.
 
Glad that you got it sorted.

I've never used the 97 versions so I can't vouch for them ;-)
 

Users who are viewing this thread

Back
Top Bottom