-1

I have gotten code from the Internet to create an Editable Data Screen that holds documents, i.e. Word docs, in a document library. I'm able to upload, download and open the files. However, I need the documents to be linked to a parent record called "Resolution". I've created the database relationship of 1 resolution to many documents but can't figure out how to have the custom screen save the child without getting an error.

I have a parent-child 1 to many relationship between parent table "Resolutions" and child table "FileInformations". I've created a custom button off the "Resolutions" detail screen to launch the " FileInformations" Editable Data Screen. I'm passing the "resolutions" ID key to the "FileInformations" Editable screen to attempt to create a bond between the parent and future child(ren) records. However, when I try to save an entry into my Editable Data Screen, it fails because it's looking for all the parent data from my "Resolutions" table. I need to know how to build a relationship between parent-child records and be able to save and ultimately retrieve the records associated with the parent.

  • this question seems a bit disorganized and idiosyncratic. Maybe rephrase as a more universal question so the audience doesn't need to look at your code to understand what you're talking about. – FistOfFury Jun 19 '14 at 19:14

1 Answers1

0

Without seeing code, this is gonna be a guess. I'm having a little trouble visualizing what you're describing.

If I understand correctly, the first thing I would try is editing the FileInformationsScreen_Saving method (or whatever your screen is called). From the screen designer, click the little arrow next to Write Code, and select the _Saving method. There, you can manually save the fields you need, by using the DataWorkspace object.

Private Sub MyScreen_Saving(ByRef handled As Boolean)
    Dim parent resolution = DataWorkspace.ApplicationData.Resolutions_SingleOrDefault(resolutionID)
    'Process the record as needed
End Sub

Hopefully this is what you're looking for. Although if the relationship between the tables is set up correctly, you should have a field in the FileInformation entity for the ID key of the "parent" Resolution, which would make all of this unnecessary.
You can verify that by looking at your tables in the designer, you should see lines connecting the related entities.

bigelowr
  • 431
  • 2
  • 11
  • What language are you working in? VB or C#? I'll post some example code. – bigelowr Sep 10 '13 at 15:12
  • I'm working in VB. Can I save a whole collection using the DataWorkspace object? Any examples are appreciated. – Angel Brinson Sep 10 '13 at 18:31
  • If this isn't what you're looking for, perhaps you could post some code, and maybe the exact error message you're getting? – bigelowr Sep 11 '13 at 16:42
  • I'm going to try the suggested code to see if it resolves my issue and I'll get back to you with the final outcome. However, I'm curious about the my parent record, "Resolution". It, also, has a child collection called Document Lbrary. So should I assume that when the Resolutionn is being saved that the child collection will be saved with it automatically even though I'll be saving the child's parent in its record manually? – Angel Brinson Sep 13 '13 at 21:40