Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create record if subform is entered

Status
Not open for further replies.

northernbeaver

Programmer
Jul 9, 2001
164
CA
I have a form that opens to a new record. the ID field sits stating autonumber (of course) now all of the controls on the form are bound and have default values entered and 97% of the time dont need to be changed. There is a subform on this form where most of the data needs to be entered. heres the problem:

the users attempt to start entering data on the sub form and is getting errors as there is no ID record yet to link to.

make sense? any ideas on how to correct it?
 
Beaverok

Have you defined your relations with the Relationship tool.

On the main menu, "Tools" -> "Relationships"

Add your tables. Define the relationships by selecting the primary key in one table and drag it to the foreign key in the related table.

It is a good idea to "Enforce referential integrity" when the popup window opens to prompt for more info on the relationship.

When you define your relationship prior to defining your queries and forms, Access will automatically link fields.

Since you probably did not define your relationship, you have to manually link the form and the subform.

Open the main form with the embedded subform in design mode. Make sure the Properties window is open. (From the menu, "View" -> "Properties")

Select a field on the main form, and then select the subform. (By selecting the main form and then the subform, forces access to display the attributes of the subform as it relates to the parent form.)

Now select the Data tab on the Properties window. Click on the Child field and open the properties window where you link the parent form to the subform via the master / child fields.

Once Access "knows" how the relationship is defined between the parent and child form, it will know to grab the primary key from the main form and use it as the foreign key in the subform.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top