Forum Discussion

Mannyg024's avatar
Mannyg024
Copper Contributor
Oct 11, 2020

Add pop up subform to add records unique to one field

I'm not sure if I'm wording this correctly. I have a main form with a field that is linked to a subform. This field will generate at least one set of numbers unique to the original field but will potentially have many sets of numbers (all corresponding to the original field). I've added a button to open the subform to add the sets of numbers. The problem I'm having is that the original field is not the primary key of the main form, so when I add sets of numbers, they are not linked to one record. Instead all sets of numbers appear in the subform. How do I create a relationship between the tables to make this work?

  • George_Hepworth's avatar
    George_Hepworth
    Silver Contributor

    Mannyg024 

    I would not open a second form. I would embed the subform in a subform control on the main form and use the Parent/Child Linking Fields  property of the subform CONTROL to handle the related fields. 

    That said, I'm not sure I follow the exact process anyway. Why are you not using the Primary Key of the table bound to the main form as the Foreign Key in the related table? 

    • Mannyg024's avatar
      Mannyg024
      Copper Contributor

      George_Hepworth 

      It might be easier to explain the process as i understand it. I have a field i'm calling MetricID in the main table/form. I created a 2nd table/subform with the MetricID field. This field will produce at least one set of numbers called MetricTag and MetricWeight. In most cases, it will produce many sets of numbers. The idea I had was to create a button next to the Metric Field in the main form that would open the dialogue box containing the 2nd subform. This didn't work, so I decided to place the subform in a tabbed field on the main form. I feel like I'm headed in the right direction, but I'm still having trouble. I will try to work with the controls like you suggested. Thanks again for your help.

Resources