Page 11 of 14
Re: Arctic reports (reporting system - Windows)
Posted: Thu Mar 13, 2014 3:45 pm
by captain_skank
Hi srod,
Does this mean I can change a reports datasource including type e.g. ODBC and username/password through code ? cos that will make my life a whole heap easier.
Re: Arctic reports (reporting system - Windows)
Posted: Thu Mar 13, 2014 3:55 pm
by srod
You can change anything through code. The whole Pyrex designer uses the nxReport core module for all report modifications; it does not access any of the report's inner structures directly.
Re: Arctic reports (reporting system - Windows)
Posted: Fri Mar 14, 2014 5:22 am
by Neil
srod wrote:No it will work on any valid report object regardless of how you loaded the report.
Before changing a subreport's datasource you need to set a current subreport with the \UseSubreport() method.
Yes the help for the nxReport core module is incomplete. The new version will not suffer such indignities!
Hi srod,
Thanks for all your advice - works great !!
Code: Select all
Procedure Button_Grades_Reports_ViewReport(EventType)
If nxReport_CatchReport(?label_ReportStart, ?label_ReportEnd - ?label_ReportStart, @report) = #nxReport_OKAY
report\UseSubreport("Page1", 0)
sString = "SELECT * FROM Configuration, Grades "
If GetGadgetState(gCheckBox_Grades_Reports_Sex_Male) And GetGadgetState(gCheckBox_Grades_Reports_Sex_Female)
ElseIf GetGadgetState(gCheckBox_Grades_Reports_Sex_Male)
sString = sString + " WHERE GradeSex = " + Chr(34) + "M" + Chr(34)
ElseIf GetGadgetState(gCheckBox_Grades_Reports_Sex_Female)
sString = sString + " WHERE GradeSex = " + Chr(34) + "F" + Chr(34)
Else
MessageRequester("Grades Reports", "Invalid selection", #PB_MessageRequester_Ok)
ProcedureReturn
EndIf
If GetGadgetState(gOption_Grades_Reports_Order_GradeNumber)
sString = sString + " ORDER BY GradeNumber"
ElseIf GetGadgetState(gOption_Grades_Reports_Order_GradeName)
sString = sString + " ORDER BY GradeName"
EndIf
report\SetCurrentSubreportDataSource(#nxReport_SQLITEDATABASE, "LacStat.s3db"+Chr(10)+sString)
report\PreviewInNewWindow(0, 0, 800, 650, "Grades: Reports", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered, 0, $47420A, #nxReport_SHOWPRINTBUTTON|#nxReport_SHOWTHUMBNAILNAVIGATION|#nxReport_MAKEMODAL, #Gray, 120)
report\Destroy()
Else
Debug "dud report"
EndIf
nxReport_RemoveTemporaryFiles() ;Just in case.
EndProcedure
DataSection
label_ReportStart:
IncludeBinary "Grades.nxr"
label_ReportEnd:
EndDataSection
Re: Arctic reports (reporting system - Windows)
Posted: Fri Mar 14, 2014 9:30 am
by srod
You're welcome Neil.
Arctic reports - Setting a Label Value from PB
Posted: Mon Mar 17, 2014 8:09 am
by Neil
Hi srod,
I am trying to set a label value for "#label_ReportOrder", but it doesn't update the report !!
Code: Select all
If GetGadgetState(gOption_Grades_Reports_Order_GradeNumber)
sString = sString + " ORDER BY GradeNumber"
sReportOrder = "Grade Number"
ElseIf GetGadgetState(gOption_Grades_Reports_Order_GradeName)
sString = sString + " ORDER BY GradeName"
sReportOrder = "Grade Name"
EndIf
sReportOrder = "Report Order: " + sReportOrder
report\SetParameter("#label_ReportOrder", sReportOrder)
report\SetCurrentSubreportDataSource(#nxReport_SQLITEDATABASE, "LacStat.s3db"+Chr(10)+sString)
report\PreviewInNewWindow(0, 0, 800, 650, "Grades: Reports", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered, 0, $47420A, #nxReport_SHOWPRINTBUTTON|#nxReport_SHOWTHUMBNAILNAVIGATION|#nxReport_MAKEMODAL, #Gray, 120)
report\Destroy()
Pyrex
Thanks
Re: Arctic reports (reporting system - Windows)
Posted: Mon Mar 17, 2014 9:20 am
by srod
Changing the ID does not change the text content. You need to alter the source for that. It's original source is set to match the original ID only when the label is first created.
Re: Arctic reports - Setting a Label Value from PB
Posted: Mon Mar 17, 2014 10:24 am
by Neil
srod wrote:Changing the ID does not change the text content. You need to alter the source for that.
So just to confirm - Are you saying that I cannot alter the text value from PB??
This will be a real hassle as it means I will have to go back to separate reports for all my options.
I want to be able to set the headers for the different report options from within PB.
Is there any other way I can achieve this ??
Does a Field work any differently than a Label ??
Thanks,
Re: Arctic reports (reporting system - Windows)
Posted: Mon Mar 17, 2014 5:48 pm
by srod
I am not saying that at all.
You can change any report-related property from PB.
Use the control\SetSource() method to change a label's text. Just have a look at some of our demo programs which create reports directly using code; you can see how to set the source and so on.
Anything you can do with Pyrex, you can do with PB code. Pyrex is written in PB and uses the nxReport core module.
You can change headers, footers... anything from PB code.
A field control allows you to enter an expression (by starting it's source text with an '=' symbol). A label just takes a literal text value.
**EDIT : ah, I see why you might be confused. When I said in my previous post that you need to change the source, I didn't mean your PB source as such, I meant that you have to alter the label control's source property as opposed to it's ID property!

You can achieve this either through Pyrex or directly through PB code.
Re: Arctic reports (reporting system - Windows)
Posted: Mon Mar 17, 2014 10:31 pm
by Neil
srod wrote:
Use the control\SetSource() method to change a label's text. Just have a look at some of our demo programs which create reports directly using code; you can see how to set the source and so on.
Hi srod,
Looking at the code examples, I can see where you change the source when creating a control.
Code: Select all
If report\AddNewControlToCurrentSubreport("#label_1_5", @control1) = #nxReport_OKAY
control1\SetType(#nxReport_LABEL)
text$ = "Please see page 2 of this report for a detailed list of nxReport's features."
control1\SetSource(text$)
I'm not sure of the syntax to use in my case.
If I try:
Code: Select all
If nxReport_CatchReport(?label_ReportStart, ?label_ReportEnd - ?label_ReportStart, @report) = #nxReport_OKAY
report\UseSubreport("Page1", 0)
sString = "SELECT * FROM Configuration, Grades "
If GetGadgetState(gCheckBox_Grades_Reports_Sex_Male) And GetGadgetState(gCheckBox_Grades_Reports_Sex_Female)
ElseIf GetGadgetState(gCheckBox_Grades_Reports_Sex_Male)
sString = sString + " WHERE GradeSex = " + Chr(34) + "M" + Chr(34)
ElseIf GetGadgetState(gCheckBox_Grades_Reports_Sex_Female)
sString = sString + " WHERE GradeSex = " + Chr(34) + "F" + Chr(34)
Else
MessageRequester("Grades Reports", "Invalid selection", #PB_MessageRequester_Ok)
ProcedureReturn
EndIf
If GetGadgetState(gOption_Grades_Reports_Order_GradeNumber)
sString = sString + " ORDER BY GradeNumber"
sReportOrder = "Grade Number"
ElseIf GetGadgetState(gOption_Grades_Reports_Order_GradeName)
sString = sString + " ORDER BY GradeName"
sReportOrder = "Grade Name"
EndIf
sReportOrder = "Report Order: " + sReportOrder
report\UseSection(#nxReport_PAGEHEADER)
report\GetControlByName("#label_ReportOrder",@report)
'-----------------------------------------
report\SetSource(sReportOrder)
;-----------------------------------------
report\SetCurrentSubreportDataSource(#nxReport_SQLITEDATABASE, "LacStat.s3db"+Chr(10)+sString)
report\PreviewInNewWindow(0, 0, 800, 650, "Grades: Reports", #PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered, 0, $47420A, #nxReport_SHOWPRINTBUTTON|#nxReport_SHOWTHUMBNAILNAVIGATION|#nxReport_MAKEMODAL, #Gray, 120)
report\Destroy()
I get:
Thanks
Re: Arctic reports (reporting system - Windows)
Posted: Tue Mar 18, 2014 10:30 am
by srod
No no no no...
Ah you haven't looked closely enough.
Your problem is here :
Code: Select all
report\GetControlByName("#label_ReportOrder",@report)
report\SetSource(sReportOrder)
The \GetControlByName() method places a nxReport_Control object into a given variable and so you need to define an appropriate variable to hold it.
Use something like :
Code: Select all
Define.nxReport_Control control
If report\GetControlByName("#label_ReportOrder",@control) = #nxReport_OKAY
control\SetSource(sReportOrder)
EndIf
Re: Arctic reports (reporting system - Windows)
Posted: Fri Mar 28, 2014 4:56 am
by Neil
srod wrote:
Use something like :
Code: Select all
Define.nxReport_Control control
If report\GetControlByName("#label_ReportOrder",@control) = #nxReport_OKAY
control\SetSource(sReportOrder)
EndIf
Hi srod,
Thanks for reply (and thanks for persevering with me !!)
ok
1. Using your code I get error "Variable already declared with different scope: control"
2. Comment out line:
Code: Select all
; Define.nxReport_Control control
If report\GetControlByName("#Label_ReportOrder",@control) = #nxReport_OKAY
Debug control\SetSource(sReportOrder)
control\SetSource(sReportOrder)
EndIf
Program compiles ok, but Debug reports "0" (and label not updated).
3. Try a different variable name:
Code: Select all
Define.nxReport_Control newcontrol
If report\GetControlByName("#Label_ReportOrder",@newcontrol) = #nxReport_OKAY
Debug newcontrol\SetSource(sReportOrder)
newcontrol\SetSource(sReportOrder)
EndIf
Program compiles ok but debug still outputs "0"
Thanks,
Neil
Re: Arctic reports (reporting system - Windows)
Posted: Fri Mar 28, 2014 12:00 pm
by srod
Well, the scope issue is clearly a problem with your program - nothing to do with Arctic Reports.
A zero return means everything is ok. (#nxReport_OKAY).
Any changes will only be visible when you preview the report anew.
Other than that, all I can say is that it works fine here. I have just tested it and ...no problems.
Re: Arctic reports (reporting system - Windows)
Posted: Sun Mar 30, 2014 7:31 am
by Neil
Hi srod
Oh dear - what can I say - most humble apologies.
I write applications at work and application problems get classed as either "OE" = Operator Error, or "PE" = Programmer Error.
I'm afraid I have to admit that this is a case of "OS" = Operator Stupidity !!
srod wrote:Well, the scope issue is clearly a problem with your program - nothing to do with Arctic Reports.
This is what originally set me off on the wrong course - I thought there was something wrong in my coding.
srod wrote:
A zero return means everything is ok. (#nxReport_OKAY).
Unfortunately this was another incorrect assumption on my part - I assumed that a result of zero was a fail.
srod wrote:
Other than that, all I can say is that it works fine here. I have just tested it and ...no problems.
It actually came to me just as i was drifting off to sleep - funny how the brain works !!.
My label actually has a bit of text at the start.
In Pyrex I have "Report Order: "
and in PB I set the value to either:
"Report Order : Name" or "Report Order: Number"
The problem was that the width of the label was not big enough to show the whole value, and so I was only seeing "Report Order: " !!!
Knowing that zero meant ok, and also that it was working for you, forced me to think of what might be happening apart from an error in the code.
Widen the label and voila - Label is changing in the report!!
I do have to comment out this line
but otherwise code is as your post.
So very sorry for wasting your time!!
Thanks,
Neil
Re: Arctic reports (reporting system - Windows)
Posted: Sun Mar 30, 2014 12:05 pm
by srod
No worries fella. Arctic Reports is a complex beastie and can take some mastering, especially the nxReport core module.
There is the \GetTextExtents() report method which, although deprecated, can be used to determine a control's nominal width etc. It is not a very flexible method mind, \ GetMinControlTextHeight() is better, but only works for heights and is intended for automatic control anchoring (where a control's height can automatically expand to accommodate whatever text it is about to display).
You can also remove 'clipping' from an individual control and thus the text will not be confined to the control's bounding rectangle etc. Course this means that all the control's text will be shoved onto a single line.
Re: Arctic reports (reporting system - Windows)
Posted: Mon Mar 31, 2014 12:13 am
by Neil
Hi srod,
Thanks for the extra advice. As you say - a very complex package, but understandable, as it does a lot of "stuff".
Also very logical once you get the hang of it - which is the main thing.
OK - for my next query.
I will have about 20 different reports that will all have the same header.
Is there a way that I only have to edit the header details once?
I know that I can copy a report and then edit it, but as you can imagine, for each instance, I fine-tune the header a bit.
One option I thought of is that is there a way to combine reports, i.e. to have one report file for the Header and one report file for the Body.
The other option, which I did actually mention before, but for another reason, is if it would be possible for you to add an option to "Save To"/"Restore From" a text file, such the user could cut and past common report details.
Thanks again,
Neil