Normal Topic SubForm Sorting (in Form View) (Read 2357 times)
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
SubForm Sorting (in Form View)
Jan 9th, 2019 at 2:18pm
Print Post Print Post  
Hello, I'm having a problem with a sub form not sorting correctly or at all in the main form. The sub form is set up as having natural links and is set to form view, rather than table view.

My goal is to have the sub records automatically display in a sorted order. That order being, descending by date. So, basically showing the most recent sub record first and so on.

I thought I had set it up correctly but it doesn't seem to be working.

Here is my code so far:

Work (SubForm) :: On Form Entry

Code
Select All
var vSort as Int

//Sorts the work jobs in descending order from the most current job to the least current job.

If @Mode() = 1
{
	vSort = @LoadSortSpec("Work_Date_Descending")

	If vSort = 1
	{
		//Causes record changed popup, but only when running preview mode from Sesame Designer.

		RunSortSpec()
	}
}
 



Any help or advice is greatly appreciated, thank you.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: SubForm Sorting (in Form View)
Reply #1 - Jan 9th, 2019 at 2:34pm
Print Post Print Post  
A subform's sort spec is stored with the parent form's sort spec. So with the parent form open, you'll want to set whatever sort spec you want for the parent form and then go to the sort spec for the subform and set it. Then bring up Spec Manager, save the spec and set it as the default sort spec. No programming needed.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: SubForm Sorting (in Form View)
Reply #2 - Jan 9th, 2019 at 10:32pm
Print Post Print Post  
Ok, cool thanks.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: SubForm Sorting (in Form View)
Reply #3 - Jan 19th, 2019 at 3:27pm
Print Post Print Post  
I've tried a few different methods but the only way I can get the sort to work is to do a search to pull up a result set in the parent form go to a record where the work subform has a few different subrecords, then go to my sort spec select "sort work" then click on the sort button for "work_date" change it to "descending" then click "run spec" or if I manually load the spec I've saved "Work_Date_Descending" and then manually click run spec. Setting as default doesn't do anything. I can't/don't need to set any specs for the parent form. Just for the work subform right now. I tried using the programming to get the sort spec to run and had some success. I  got the sort spec to actually load and I could see that it was loaded and all I would have to do is to click "run spec" but it wasn't running the spec automatically with the "RunSortSpec()" command. However, I would get prompted automatically on retrieval of the ResultSet that it was modified and would I like to continue, then when running the spec I would get the same prompt, so two click-throughs to run a sort spec. I'm also now running this programming from the parent form On Form Entry for Update Mode, instead of from the Work subform's programming, so maybe that's the problem. I read through the spec commands in the programming guide and read through the sorting section in the user guide and I still can't figure out how to get this to sort automatically with minimal user input.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: SubForm Sorting (in Form View)
Reply #4 - Jan 21st, 2019 at 2:06pm
Print Post Print Post  
First step is to take out the programming. Next open the parent form and switch to Sort Work spec window. Set your sort spec up like you want it. Switch back to the Sort spec for the parent form. Left click and choose Save. Save the spec and set it as the default. It will load the blank parent sort and the sort for the Work form when the form loads.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: SubForm Sorting (in Form View)
Reply #5 - Jan 24th, 2019 at 2:56pm
Print Post Print Post  
Ok thanks I'll try that.
  
Back to top
 
IP Logged