Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    3

    Unanswered: One to many relation - adding new entries via forms

    Hi,
    I have two tables,

    One called Company details , with various fields. The second table is news & information about a given company in the first table - so you can have many news items about 1 company. I created an autonumber primary key in the first table called company_name_id and the second table has the same field and it has a lookup of the company_name_id in the first table. I created a one to many relationship.

    I have created a form via a wizard , so now when I choose a given company I can access the news&information relevant to that company via a subform. The problem is when I create a new news&info record for a given company (via the subform) it somehow is unable to relate the new record to the company. I have to manually put in the company_id again.

    Not sure what's wrong..

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    In the OnEnter event for the subform, set the DefaultValue of company_id on the subform to be the value from the main form.

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Question Re: One to many relation - adding new entries via forms

    Originally posted by themandarin
    Hi,
    I have two tables,

    One called Company details , with various fields. The second table is news & information about a given company in the first table - so you can have many news items about 1 company. I created an autonumber primary key in the first table called company_name_id and the second table has the same field and it has a lookup of the company_name_id in the first table. I created a one to many relationship.

    I have created a form via a wizard , so now when I choose a given company I can access the news&information relevant to that company via a subform. The problem is when I create a new news&info record for a given company (via the subform) it somehow is unable to relate the new record to the company. I have to manually put in the company_id again.

    Not sure what's wrong..
    Shouldn't have to use an event procedure for that. I think something

    else is not set up right. My subforms always pick up the one to many

    relationship with the parent form. Are the LinkChildFields and

    LinkMasterFields set up? Did you include the linking field in the subform

    (doesn't have to be a control on the form just be available in the

    underlying data source)?

    Gregg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •