cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
LIL
Level: Powered On

Relationship between forms

Hi, 

I'm looking for if it is possible to create a form that contains subform.

Each form uses a different table as a source, the relationship between the tables is one to many.

When we using the main form to add a new record to the parent table, there is an ID Number created. The subform should use this ID Number automatically for new records in the child table.

Can I do it with PowerApp?  Or is there another concept that could work in the same way?

 

1 ACCEPTED SOLUTION

Accepted Solutions
egallis
Level 10

Re: Relationship between forms

Hello @LIL,

If I understand well, you have a "master" form connected to a datasource A and another "slave" form connected to a datasource B which holds a "linked" column to the master form (ie datasource A). And you would like the following behavior:

  • you create a new item in the master form and save it
  • once it's created, you would like to create records in the slave form storing automatically for each record the ID of the previously created master record

If that's what you want to achieve, here is what I suggest you to do:

  • on your canvas, insert the two forms and link each one of them to their corresponding datasource (A for master, B for slave)
  • add a Save button to save your master record by setting its OnSelect property to:
SubmitForm(yourMasterForm);Set(VAR_MasterID,yourMasterForm.LastSubmit.ID)
  • then, in your slave form, set the Default property of your column that is linked to your datasource A to the following value:
VAR_MasterID
  • finally, add a Save button to save your slave record by setting its OnSelect property to:
SubmitForm(yourSlaveForm)

I hope I've answered your question here... 🙂

Emmanuel

View solution in original post

5 REPLIES 5
egallis
Level 10

Re: Relationship between forms

Hello @LIL,

If I understand well, you have a "master" form connected to a datasource A and another "slave" form connected to a datasource B which holds a "linked" column to the master form (ie datasource A). And you would like the following behavior:

  • you create a new item in the master form and save it
  • once it's created, you would like to create records in the slave form storing automatically for each record the ID of the previously created master record

If that's what you want to achieve, here is what I suggest you to do:

  • on your canvas, insert the two forms and link each one of them to their corresponding datasource (A for master, B for slave)
  • add a Save button to save your master record by setting its OnSelect property to:
SubmitForm(yourMasterForm);Set(VAR_MasterID,yourMasterForm.LastSubmit.ID)
  • then, in your slave form, set the Default property of your column that is linked to your datasource A to the following value:
VAR_MasterID
  • finally, add a Save button to save your slave record by setting its OnSelect property to:
SubmitForm(yourSlaveForm)

I hope I've answered your question here... 🙂

Emmanuel

View solution in original post

tommyly
Level 8

Re: Relationship between forms

Forms cannot be nested within a form (like you would in an Access form/subform); however, you can create a relationship between two forms. For example, let's assume you have a Company datasource (Form1) and an Employee datasource (Form2).

 

Create a field for Employee datasource to the effect of CompanyID. In the Form2 datacard, you would set DataCardCompanyID.Default = Form1.DataCardID.Default.

 

You will have to make sure Form2 is only enabled if Form1 has a valid record.

egallis
Level 10

Re: Relationship between forms

@tommyly, you are right: forms cannot be nested. And if you look closely to my post you will see I didn't suggest to nest them, just to insert them on the canvas (I meant, side by side; but may be it was not clear enough). Thanks for pointing that out...

tommyly
Level 8

Re: Relationship between forms

Sorry, I was writing in context of the OP's post, not yours. I didn't even see yours until I hit Post. I think you are spot on though; and in some cases, it may even be appropriate to navigate the user to another screen.

LIL
Level: Powered On

Re: Relationship between forms

That's exactly what I wanted!

Thanks a lot!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 85 members 5,263 guests
Please welcome our newest community members: