Results 1 to 15 of 15
  1. #1
    Join Date
    Apr 2004
    Posts
    182

    Unanswered: read autonum from mainform to subform

    I am using a main form and sub form for data entry . I want the autonum from the mainform to be carried down to the subform automatically. This field is the master/child link.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    If your relation of the mainForm and subForm are correct, the Auto Num (Key) would automatically copied from the main- to the SubForm when you enter new data in the subform.

  3. #3
    Join Date
    May 2004
    Posts
    3

    try this

    Try setting the "Default Value" property of the subform key field, equal to the mainform key field (e.g. =[Forms]![MainForm]![Key]) and the "Control Source" property (of the Subform key field) equal the the field you're saving it in. works like a charm

  4. #4
    Join Date
    Apr 2004
    Posts
    182
    I am entering the data to both forms at the same time so I dont think the autonum has been saved before I add the data tp the sub form. I get an error saying I cannot leave the PK (autonum) enpty in the subform.

  5. #5
    Join Date
    Apr 2004
    Posts
    182
    I tried setting the Default value but still I get the PK error ???

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    How did you create your form? I normally dont make the PK of the subform the same as the PK of the main form. I normally have 2 different PK's. Maybe I am missunderstanding your problem. Could you explain a bit more?

    Also you may want to try to use the form wizard to see if you can make it work that way then use that as like a template for the form you are trying to make work now.

    Hope I can help,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  7. #7
    Join Date
    Apr 2004
    Posts
    182
    The PK on main form is estid the PK on subform is concatenated key of estid and matdesc. The form is complicated. It has a series of combo boxes which on change change the recourd source for the next combo box and it also has text fields. The sub form is the same main form is for estimate details and sub form is for materials required for the job. It os very difficult to explain sorry.

  8. #8
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Aye, Dont apologize.

    Okay you have a PK that is made up of 2 fields in the subform? The PK and then the other thing right the 'matdesc' I am assuming from everything you told me that is the Material Description.

    So for the subform to work properly the main form has to have its PK first correct? Is the PK on the main form an AutoNumber field?

    To make an autonumber field genterate its number you first have to enter/change data on one control on the main form and goto another control. Then you should be able to grab the value of estid.value and make it do what it is supposed to. (like in an afterupdate event)

    I hope I can help further... Let me know how you are progressing to this point, and if I have made any sense at all.

    JS

    Quote Originally Posted by livvie
    The PK on main form is estid the PK on subform is concatenated key of estid and matdesc. The form is complicated. It has a series of combo boxes which on change change the recourd source for the next combo box and it also has text fields. The sub form is the same main form is for estimate details and sub form is for materials required for the job. It os very difficult to explain sorry.
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  9. #9
    Join Date
    Apr 2004
    Posts
    182
    You understand perfectly.The problem is that I am adding the rec using AddNew - I am looking at a way around this now.

  10. #10
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    You are adding the record using AddNew? In VBA Code? Could you explain the process maybe I can assist further or we can together come up with a better process (or atleast one that will work for you).

    JS

    Quote Originally Posted by livvie
    You understand perfectly.The problem is that I am adding the rec using AddNew - I am looking at a way around this now.
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  11. #11
    Join Date
    Apr 2004
    Posts
    182
    I have been using VBA code as it is an Access Project ADP. I am trying to do it now using Access Data Entry and I am getting Write Conflict errors.
    Originally I wanted to enter estimate details in the main form and in the subform enter the material requirements for this estimate.

  12. #12
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    I totally understand that... I have several things I have to keep track of like that... Sales Orders, Work Orders, Caulk Inventory. I also had an estimate system worked out.

    What are your tables like? I am assuming you have atleast two tables, right?

    I have never used the primary key from the main form to the subform though, but what I have done before is used the PK in main as a FK (foreign key) in the sub. and make the sub have its own autonum PK

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  13. #13
    Join Date
    Apr 2004
    Posts
    182
    I have about 6 tables. The reason I have used the PK as part of the PK in the subform is that it is the only thinkg that uniquely id's it. I will try creating a new PK for the subform.

  14. #14
    Join Date
    Apr 2004
    Posts
    182
    Hey JS thanks for you time on this. I created the forms again designed differently and it seems to be working ok now. Thanks

  15. #15
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    I am glad to hear that. Awesome. Glad I could help some.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

Posting Permissions

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