cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

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
Highlighted
Resident Rockstar
Resident Rockstar

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
Highlighted
Resident Rockstar
Resident Rockstar

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

Highlighted
Responsive Resident
Responsive Resident

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.

Highlighted
Resident Rockstar
Resident Rockstar

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...

Highlighted
Responsive Resident
Responsive Resident

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.

Highlighted
New Member

Re: Relationship between forms

That's exactly what I wanted!

Thanks a lot!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,268)