Arctic reports (reporting system - Windows)
- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: Arctic reports (reporting system - Windows)
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.
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)
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.
I may look like a mule, but I'm not a complete ass.
Re: Arctic reports (reporting system - Windows)
Hi srod,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!![]()
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)
You're welcome Neil.
I may look like a mule, but I'm not a complete ass.
Arctic reports - Setting a Label Value from PB
Hi srod,
I am trying to set a label value for "#label_ReportOrder", but it doesn't update the report !!
Pyrex

Thanks
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()

Thanks
Re: Arctic reports (reporting system - Windows)
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.
I may look like a mule, but I'm not a complete ass.
Re: Arctic reports - Setting a Label Value from PB
So just to confirm - Are you saying that I cannot alter the text value from PB??srod wrote:Changing the ID does not change the text content. You need to alter the source for that.
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)
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.
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!

I may look like a mule, but I'm not a complete ass.
Re: Arctic reports (reporting system - Windows)
Hi srod,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.
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$)
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()

Thanks
Re: Arctic reports (reporting system - Windows)
No no no no... 
Ah you haven't looked closely enough.
Your problem is here :
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 :

Ah you haven't looked closely enough.
Your problem is here :
Code: Select all
report\GetControlByName("#label_ReportOrder",@report)
report\SetSource(sReportOrder)
Use something like :
Code: Select all
Define.nxReport_Control control
If report\GetControlByName("#label_ReportOrder",@control) = #nxReport_OKAY
control\SetSource(sReportOrder)
EndIf
I may look like a mule, but I'm not a complete ass.
Re: Arctic reports (reporting system - Windows)
Hi srod,srod wrote: Use something like :
Code: Select all
Define.nxReport_Control control If report\GetControlByName("#label_ReportOrder",@control) = #nxReport_OKAY control\SetSource(sReportOrder) EndIf
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
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
Thanks,
Neil
Re: Arctic reports (reporting system - Windows)
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.

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.
I may look like a mule, but I'm not a complete ass.
Re: Arctic reports (reporting system - Windows)
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 !!
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
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 !!
This is what originally set me off on the wrong course - I thought there was something wrong in my coding.srod wrote:Well, the scope issue is clearly a problem with your program - nothing to do with Arctic Reports.![]()
Unfortunately this was another incorrect assumption on my part - I assumed that a result of zero was a fail.srod wrote: A zero return means everything is ok. (#nxReport_OKAY).
It actually came to me just as i was drifting off to sleep - funny how the brain works !!.srod wrote: Other than that, all I can say is that it works fine here. I have just tested it and ...no problems.
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
Code: Select all
; Define.nxReport_Control control
So very sorry for wasting your time!!
Thanks,
Neil
Re: Arctic reports (reporting system - Windows)

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.
I may look like a mule, but I'm not a complete ass.
Re: Arctic reports (reporting system - Windows)
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
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