The following code is in the click action of a button.  The form contains 
several grids, one of which lists student names.  A table is created for each 
new student; that table must then be accessed to create the appropriate 
report; that is what the addition of 100000 achieves.

#get current student id and name; id is used to target correct student table 
by adding 100000 (student table series)
colstudent=hk_thisform.get_pyvisible("gridstudent").datasource().column_by_name("studentid")
colstudentvalue=colstudent.asinteger() + 100000
studentname=hk_thisform.get_pyvisible("gridstudent").datasource().column_by_name("studentfname").asstring()
 
+ " " + 
hk_thisform.get_pyvisible("gridstudent").datasource().column_by_name("studentlname").asstring()

#get report dates, if blank set to default values

rptstartdate=hk_thisform.get_pyvisible("rptstartdate").value()
rptenddate=hk_thisform.get_pyvisible("rptenddate").value()

#set up sqlstr
sqlstr="SELECT '" + studentname + "' AS \"studentname\", to_char(\"T0\".
\"studactstart\", 'Day, DD-Mon-YY') || '; ' || \"T2\".
\"coursename\" || '; ' || \"T0\".\"studacttopic\" || '; ' || \"T3\".
\"restitle\" || '; ' || \"T0\".\"studactref\" AS \"prtstring\" , \"T0\".
\"studactinstructions\" As \"Instructions\", \"T0\".\"studacttype\" ,  
\"T0\".\"studactend\" , \"T0\".\"studacttime\" FROM \"" + 
str(colstudentvalue) + "\" \"T0\" LEFT JOIN \"tblsubject\" \"T1\" ON (\"T1\".
\"subjectid\"=\"T0\".\"studactsubjectid\") LEFT JOIN \"tblcourses\" \"T2\" ON 
(\"T2\".\"courseid\"=\"T0\".\"studactcourseid\") LEFT JOIN \"tblresource\" 
\"T3\" ON (\"T3\".\"resid\"=\"T0\".\"studactres\") WHERE \"T0\".
\"studactend\" IS Null AND \"T0\".\"studactstart\" >= '" + str(rptstartdate) 
+ "' AND \"T0\".\"studactstart\" <= '" + str(rptenddate) + "' ORDER BY 
\"T0\".\"studactstart\""

hk_this.show_warningmessage(sqlstr)

myreport=hk_thisform.database().new_reportvisible()
myreport.load_report("rptPendingStudentActivity")
myreport.datasource().disable()
myreport.datasource().set_sql(sqlstr)
myreport.datasource().enable()

myreport.set_mode(myreport.viewmode)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Hk-classes-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hk-classes-discuss

Reply via email to