Populating Form's Subform from unrelated Report

Populating Form's Subform from unrelated Report

Hi Guys,

I’m trying to make a button in a report that, when multiple records are selected, it will run through the records, collect some of the fields from the records, then open up another form in a popup window and populate it’s subform with said fields. Essentially, each selected record in one report would need to be a row in the subform of a newly opened form.

I’m getting some errors on what I've tried, which may be to do with using the usual Insert rows in Subform tactic; I have no idea if this can work with Functionality based URLs, but I'm not sure how else to open a pop up of a populated but unsaved record.

Here’s a stripped down version of the code I’m having problems with:

Report with button that appears when multiple records are selected = Returns
Form to open and populate = Resell
Subform to populate = Items (so 'Resell.Items')

  1. void ResellAll.ResellAll(Returns resellall)
  2. {
  3. // This is just declaring Collections and Variables and works fine.
  4. returnItemIDs = "";
  5. SKUs = "";
  6. subrows = Collection();

  7. // The following line (and the related lines in the For Each loop) are causing the error messages: 'Value is empty and function cannot be applied'
  8. ItemsSubform = Resell.Items();

  9. // For each row selected in the report, add a row to the Collection
  10. for each  r in resellall
  11. {
  12.         ItemsSubform.Return_Item_Multi=r.ID;
  13.         ItemsSubform.SKU_Multi=r.SKU;
  14.         ItemsSubform.Name_Multi=r.Name;
  15.         subrows.insert(ItemsSubform);
  16. }

  17. // This is used to open the popup window and auto populate some of its values via the Collection.
  18. url = "#Form:Resell?Items=" + subrows;
  19. info url;
  20. openUrl(url,"popup window");
  21. }
Note that this may work for creating and then referencing a record, but I really need it to be an unsaved record so my portal users can edit it or cancel it before saving.

If anyone can point me in the right direction, I’d appreciate it, or if you need more info to help then let me know.