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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding new record via subform 1

Status
Not open for further replies.

eadiem

Technical User
Apr 8, 2004
47
CA
Hi,
I have a subform called "Varieties" on a main form called "All Farms". The All Farms form displays information for each farm, one at a time. The varieties subform is a continuous form showing information about all the varieties found on that farm. I have an ID field which is a PK on All Farms, and which has a 1:many relationship to ID on Varieties. The ID field is set to "Visible = false" on the Varieties subform to avoid confusion.

I want my user to be able to edit/add/delete records in Varieties. All buttons work correctly except "Add". When a user adds a record and specifies the details, the details are added to the table but the ID is 0.

How can I get the new record to keep the same ID as the ID on the main form?

Many thanks in advance
Eadie
 
Take a look at the LinkChildFields and LinkMasterFields properties of the subform.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ooops...sorry!!
I got confused with a different part of the form.
Sorry...the Varieties form is not actually a subform. It opens when a user clicks a button on the main form.
 
You may play with OpenArgs setting the DefaultValue property of the ID control.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
That's a great idea.
I set the defaultvalue to:
Forms![All Farms]!ID
Seems to work so far, will do some more checking. Thankyou!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top