Paradox Community

Items in pnews.paradox-programming

Subject:Re: Help with writing tcursor
Date:Sat, 23 May 2020 19:10:56 +0200
From:modridirkac <jure.zorko@gmail.com>
Newsgroups:pnews.paradox-programming
Just typing from may head, did not test this:

var i integer;
     d1, d2 date ; dates start-end
     s1, s2 string
     q query
     y smallint  ; year, you are looking at
     mon string ; month (fpr query)
     T Table
endVar
y = year(today())  ; or you coul just set it: y=2019
for i from 1 to 12     ;  for each month
   d1 = date(i,1,y)   ; start date
   d2 = date(i,DaysInMonth(d1),y))  ; last day of month
   s1 = string(d1)
   s2 = string(d2)
   mon = moy(d1)
   q = Query

     Giving.DB | MainId          | Date          |  
Amount                                   | Category        |
	  | Check not blank | >=~s1,<=~s2   | calc sum as Total, calc ~mon as  
"Month" | check not Split |
				
   endQuery
   if i = 1 then   ; first time, create final table
     if not q.ExecuteQBE(":PRIV:CT2.DB") then errorshow() return endIf
   else
     if not q.ExecuteQBE(":PRIV:_tmp"+string(i)) then errorshow() return  
endIf   ; create temp table, then add to main table
     T.Attach(":PRIV:_tmp"+string(i))
     T.Add(":PRIV:CT2.DB")
     T.UnAttach()
   endIf

endFor


Copyright © 2004 thedbcommunity.com