Normal Topic [Solved] Sorting and PrintAReport (Read 1032 times)
dhopkins
Member
*
Offline



Posts: 47
Joined: Aug 20th, 2007
[Solved] Sorting and PrintAReport
Feb 6th, 2008 at 10:50pm
Print Post Print Post  
I'm having a problem getting reports to sort by time. I have a subroutine that uses PrintAReport to create reports when a user chooses a date and clicks a button.
It takes the  date and runs a speccommand retrieve, then a spec command sort (based on a time field:ex. 9:45am), and then prints the report. The problem is that its not sorting. I've tried making the sort spec the default for the form and the report, but still, the reports are out of order. Am I missing something?


if it helps, here's the subroutine

Code
Select All
#include "sbasic_include.sbas"
subroutine create_reports(store_list as String)
var vTmp as Int
var vList as String
var cur_store as String
var element_count as int
var loop as int
var temp_date as String
var total_orders as int
var total_final as int
total_orders = 0
total_final = 0
temp_date = Delivery Date
if (@IsBlank(Delivery Date))
{
	@MsgBox("","You Must Enter a Date","")

}
else
{
element_count = @CountStringArray(store_list)

	If @Mode() = 1
	{
		vTmp = @SelectTreeItem("Search Update Menu!Search (F7)")
	}
	If @Mode() = 2
	{
		For loop = 1 to element_count
			temp_date = Delivery Date

			cur_store = Split(store_list,";")
			vTmp = @SelectTreeItem("Search Update Menu!Search (F7)")

			Location = cur_store
			vList = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_RETRIEVE, "")
			vList = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_SORT, "- Quick Report Sort")
			total_orders = @ResultSetTotal()
			if (@mode() = 1)
			{

			vTmp = @PrintAReport("- LUNCH REPORT", REPORT_MODE_HTML, PRINT_ORIENTATION_PORTRAIT, PRINT_NO_DIALOG, -1, -1, -1, -1, -1, -1)
			writeln("Creating Lunch Report for "+cur_store+ ". " +total_orders + " orders "+Delivery Date)
			total_final =  total_final + total_orders
			}
			else
			{
			writeln("Skipped "+cur_store+ ". No orders on "+Delivery Date)

			}
			total_orders = 0
			Delivery Date = temp_date

		Next

	}



writeln("There were "+total_final +" orders in all")
}
end subroutine 



Thanks,
D
« Last Edit: Feb 12th, 2008 at 12:39pm by Hammer »  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Sorting and PrintAReport
Reply #1 - Feb 7th, 2008 at 3:25pm
Print Post Print Post  
Stupid question: If you just run the saved sort called "- Quick Report Sort", are the records in the correct order?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
dhopkins
Member
*
Offline



Posts: 47
Joined: Aug 20th, 2007
Re: Sorting and PrintAReport
Reply #2 - Feb 7th, 2008 at 5:36pm
Print Post Print Post  
Yes, If I just do a regular search and then run the sort, the report is sorted. Also, if I run the search and just run the report from the menu, it's sorted. But when I send it through the printareport routine, its unsorted.

D
  
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: Sorting and PrintAReport
Reply #3 - Feb 7th, 2008 at 5:57pm
Print Post Print Post  
Try

Code
Select All
#include "sbasic_include.sbas"
subroutine create_reports(store_list as String)
var vTmp as Int
var vList as String
var cur_store as String
var element_count as int
var loop as int
var temp_date as String
var total_orders as int
var total_final as int
total_orders = 0
total_final = 0
temp_date = Delivery Date
if (@IsBlank(Delivery Date))
{
	@MsgBox("","You Must Enter a Date","")

}
else
{
element_count = @CountStringArray(store_list)

	If @Mode() = 1
	{
		vTmp = @SelectTreeItem("Search Update Menu!Search (F7)")
	}
	If @Mode() = 2
	{
		For loop = 1 to element_count
			temp_date = Delivery Date

			cur_store = Split(store_list,";")
			vTmp = @SelectTreeItem("Search Update Menu!Search (F7)")

			Location = cur_store
			vList = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_RETRIEVE, "")
			vList = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_SORT, "- Quick Report Sort")
			vList = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_SORT, "")
			total_orders = @ResultSetTotal()
			if (@mode() = 1)
			{

			vTmp = @PrintAReport("- LUNCH REPORT", REPORT_MODE_HTML, PRINT_ORIENTATION_PORTRAIT, PRINT_NO_DIALOG, -1, -1, -1, -1, -1, -1)
			writeln("Creating Lunch Report for "+cur_store+ ". " +total_orders + " orders "+Delivery Date)
			total_final =  total_final + total_orders
			}
			else
			{
			writeln("Skipped "+cur_store+ ". No orders on "+Delivery Date)

			}
			total_orders = 0
			Delivery Date = temp_date

		Next

	}



writeln("There were "+total_final +" orders in all")
}
end subroutine  



-Ray
  

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



Posts: 47
Joined: Aug 20th, 2007
Re: Sorting and PrintAReport
Reply #4 - Feb 12th, 2008 at 12:21am
Print Post Print Post  
Sorry, that didnt work.

If I run the report by clicking on the reports menu link it sorts just fine. But when I use the programmed button, it's out of order. I even tried loading the sort spec by hand and then clicking the button, but that failed also.

I think it's has something to do with the way I'm loading the sort spec or running it. Its a mystery to me.


D
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Sorting and PrintAReport
Reply #5 - Feb 12th, 2008 at 12:53am
Print Post Print Post  
One of the other things you tried may be getting in the way. Make sure you do not still have a sort spec attached to the report.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
dhopkins
Member
*
Offline



Posts: 47
Joined: Aug 20th, 2007
Re: Sorting and PrintAReport
Reply #6 - Feb 12th, 2008 at 2:14am
Print Post Print Post  
Thanks! That worked. I had added another sort spec and once I removed it, the reports were sorted correctly when using the command button.


D
  
Back to top
 
IP Logged