|
|
 | | From: | Heinz Kesting | | Subject: | How to refer to report params | | Date: | Sun, 2 Jan 2005 22:15:57 +0100 |
|
|
 | Hi everybody, To a report some params are passed by the procedure file which calls the report. In the report these params, one by one will be assigned to the variables and report properties needed for the report. At the moment I determine what param is to assign to what property by the length of the name given in the proccedure file. For the index of the report rowset, for instance, I use
_app.main.repView.params["indx"] = _app.main.q_pat.rowset.indexname
in the calling proc. In the report I have a DO CASE construct for assigning it to the corresponding property, like
cKey = r.ReportViewer.params.firstKey for i = 1 to r.ReportViewer.params.count() pLen = len(cKey) do case ... case pLen = 4 // Parameter Index cINDEX = r.ReportViewer.params[cKey] ... endcase cKey = r.ReportViewer.params.nextKey(cKey) next i r.q_pat.rowset.indexName = cINDEX
This works fine, no problem about it. But can't this be done by the real names of the params? I think the code would be much easier to read after some time if it was about the name and not the length of the param. However, I didn't find a way to refer to the names. So I wonder if this way is "state of the art" to do this, or are there better chances?
Thanks for helping, Heinz
|
|
 | | From: | Michael Nuwer [dBVIPS] | | Subject: | Re: How to refer to report params | | Date: | Sun, 02 Jan 2005 20:02:53 -0500 |
|
|
 | Heinz Kesting wrote: > > This works fine, no problem about it. But can't this be done by the real > names of the params? > I think the code would be much easier to read after some time if it was > about the name and not the length of the param. However, I didn't find a way > to refer to the names. So I wonder if this way is "state of the art" to do > this, or are there better chances?
Does the following line work in place of the Case statement?
r.q_pat.rowset.indexName = r.ReportViewer.params["indx"]
-- Michael Nuwer http://www.nuwermj.potsdam.edu/dLearn/ http://www.nuwermj.potsdam.edu/dSamples/
"I would rather be vaguely right, than precisely wrong." -- John Maynard Keynes
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Mon, 3 Jan 2005 21:39:37 +0100 |
|
|
 | Hi Michael > > Does the following line work in place of the Case statement? > > r.q_pat.rowset.indexName = r.ReportViewer.params["indx"]
No, it produces an "incompatible data type" error. (Required data type: object).
Thanks for replying! Best regards, Heinz
|
|
 | | From: | Michael Nuwer [dBVIPS] | | Subject: | Re: How to refer to report params | | Date: | Tue, 04 Jan 2005 07:00:31 -0500 |
|
|
 | Heinz Kesting wrote: > Hi Michael > >>Does the following line work in place of the Case statement? >> >>r.q_pat.rowset.indexName = r.ReportViewer.params["indx"] > > > No, it produces an "incompatible data type" error. (Required data type: > object).
That sounds odd to me. If you can do this: cINDEX = r.ReportViewer.params[cKey] r.q_pat.rowset.indexName = cINDEX
I can't see a reason why you can't do this: r.q_pat.rowset.indexName = r.ReportViewer.params["indx"]
Perhaps something more is going on in your code. If you would be willing to post your program and report files in the binaries group, I'd be willing to look at them.
-- Michael Nuwer http://www.nuwermj.potsdam.edu/dLearn/ http://www.nuwermj.potsdam.edu/dSamples/
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Tue, 4 Jan 2005 22:55:12 +0100 |
|
|
 | Hi Michael > Perhaps something more is going on in your code. If you would be > willing to post your program and report files in the binaries group, I'd > be willing to look at them.
I'm glad to have that chance. I posted a ZIP file with the Startup.prg, the Main.wfm (Mainform with some Subforms), the Procedures.prg (containing all procedures and functions) and the Preview.rep (the app's most important Report).
Take a look at in the Procedures.prg. Here you will see 6 params defined for the report, neatly lined up, each param name 1 char longer than the previous one. Then in the Preview.rep you will find the mentioned DO CASE construct for the "WHO IS WHO" of the params. The other two files are just included in case you need to look at the whole thing ... I hope you'll find your way through this mess of a beginner ...
Thanks a Great Lot for helping! Best regards, Heinz
|
|
 | | From: | Michael Nuwer [dBVIPS] | | Subject: | Re: How to refer to report params | | Date: | Tue, 04 Jan 2005 18:36:49 -0500 |
|
|
 | Heinz Kesting wrote: > > I'm glad to have that chance. I posted a ZIP file with the Startup.prg, the > Main.wfm (Mainform with some Subforms), the Procedures.prg (containing all > procedures and functions) and the Preview.rep (the app's most important > Report).
Hi Heinz,
The zip file has ProcedureN.prg, but not ProcedureS.prg. Would you please post the "S" procedure file.
> Take a look at in the Procedures.prg. Here you will see > 6 params defined for the report, neatly lined up, each param name 1 char > longer than the previous one. Then in the Preview.rep you will find the > mentioned DO CASE construct for the "WHO IS WHO" of the params. The other > two files are just included in case you need to look at the whole thing ... > I hope you'll find your way through this mess of a beginner ...
I think I'll be able to find my way. It's not really much of a mess. Actually, I admire reading coding that is, like yours, systematically organized.
-- Michael Nuwer http://www.nuwermj.potsdam.edu/dLearn/ http://www.nuwermj.potsdam.edu/dSamples/
"I would rather be vaguely right, than precisely wrong." -- John Maynard Keynes
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Wed, 5 Jan 2005 17:59:20 +0100 |
|
|
 | Hi Michael > > The zip file has ProcedureN.prg, but not ProcedureS.prg. Would you > please post the "S" procedure file. Silly me, an "updated" ZIP has right now been launched into the binaries ....> > > Take a look at in the Procedures.prg. Here you will see > > 6 params defined for the report, neatly lined up, each param name 1 char > > longer than the previous one. Then in the Preview.rep you will find the > > mentioned DO CASE construct for the "WHO IS WHO" of the params. The other > > two files are just included in case you need to look at the whole thing .... > > I hope you'll find your way through this mess of a beginner ... > > I think I'll be able to find my way. It's not really much of a mess. > Actually, I admire reading coding that is, like yours, systematically > organized. Well, that's nice to hear, maybe it's one of the (few good) typical German features, although I have to confess that it dimished with the increasing number of functions, refering to the naming of the functions and the comments of certain cornerstones in the code ... But please, don't hold back, if you see things that really should be done in a different manner.
I do appreciate your help and the time you spend!
Best regards, Heinz
|
|
 | | From: | Michael Nuwer [dBVIPS] | | Subject: | Re: How to refer to report params | | Date: | Wed, 05 Jan 2005 15:46:53 -0500 |
|
|
 | Heinz Kesting wrote:
> But please, don't hold back, if you see things that really should be done in > a different manner.
Unfortunately I cannot see any reason why the report's bootstrap code cannot reference the params array by name. It should work, as the example I posted demonstrates. Your code is, of course, more complex than my example. Perhaps something related to the use of subforms or _app properties or something else, is causing the problem. But I don't really see why that would be so. Another possibility is that there is a bug causing this problem.
Be that as it may, I think there is an easier way to render your report. Assuming that you are using dBASE Plus, you should be able to bypass the params array altogether. Below is a substitute AV_onOpen function (untested, of course). In this code, the parameters are set directly in the report. The last line is what makes this possible and that is the feature which was added with dBASE Plus.
function AV_OnOpen do case case _app.main.q_rech.rowset.fields["R_Art"].value = "KoVo" _app.aview.cTitle = "Kostenvoranschlag" case _app.main.q_rech.rowset.fields["R_Art"].value = "LiQu" _app.aview.cTitle = "Labor-Rechnung" case _app.main.q_rech.rowset.fields["R_Art"].value = "FiRe" _app.aview.cTitle = "Fiktiv-Rechnung" case _app.main.q_rech.rowset.fields["R_Art"].value = "Stor" _app.aview.cTitle = "STORNO" otherwise msgbox("Rech.Art = " + _app.main.q_rech.rowset.fields["R_Art"].value, "Rechnungsart nicht definiert", 16) _app.aview.cTitle = "Labor-Rechnung" endcase
set proc to preview.rep addi r = new PREVIEWReport() r.output = 0 r.pt.marginLeft = 0.6 r.pt.r_titel.text = _app.aview.cTitle + " ( K O P I E )" r.pt.datum.text = "vom " + ; _app.main.q_rech.rowset.fields["Datum"].value r.q_pat.rowset.setrange(_app.aview.cPat) r.q_rech.rowset.setrange(_app.aview.cRech) _app.aview.repView.ref = r return
> I do appreciate your help and the time you spend!
I hope my comments help.
-- Michael Nuwer http://www.nuwermj.potsdam.edu/dLearn/ http://www.nuwermj.potsdam.edu/dSamples/
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Thu, 6 Jan 2005 22:50:54 +0100 |
|
|
 | Hi Michael, I'd never understood what the property "ref" of a ReportViewer is good for without a living example ... At least not from reading the rather short help text. So it could save me from the slightly strange report bootstrap code. > set proc to preview.rep addi > r = new PREVIEWReport() > r.output = 0 > r.pt.marginLeft = 0.6 > r.pt.r_titel.text = _app.aview.cTitle + " ( K O P I E )" > r.pt.datum.text = "vom " + ; > _app.main.q_rech.rowset.fields["Datum"].value > r.q_pat.rowset.setrange(_app.aview.cPat) > r.q_rech.rowset.setrange(_app.aview.cRech) > _app.aview.repView.ref = r > return Unfortunately it works only for r.output = 0 // sceen
If I set this to print with the following: function AV_PB_Print_OC if _app.printer.chooseprinter(" CalcuLab: Drucker und Druckeinstellungen wählen") = true set procedure to preview.rep additive r = new PREVIEWReport() r.output = 1 // Ausgabe auf Drucker r.pt.marginLeft = 2.105 // Linker Rand für Ausdruck r.pt.r_titel.text = _app.aview.cTitle + " ( K O P I E )" r.pt.datum.text = "vom " + _app.aview.cDate r.q_pat.rowset.setrange(_app.aview.cPat) r.q_rech.rowset.setrange(_app.aview.cRech) _app.aview.repView.ref = r // alle Parameter an den Report übergeben _app.aview.repview.reexecute() endif it doesn't print, although I can see the change in the left margin, which tells me that (only some or ALL ??) parameters are passed to the report. There is never a printjob sent, wether I use the "reexecute()" command or not, not even if I set the output to printer in the function AV_OnOpen, which is called first and is to display the preview of the invoice. (In this case the preview should be printed immediately, but is sent to screen, as if output would be 0 for screen). Next I tried with "output = 4" as a HTML file, but nothings ever happens but displaying the report on the monitor. I'm using dbase plus 2.21 under Win 2000. And here's another question about the reportViewer. The wheel mouse does not function on the reportViewer, neither on my machine nor on the machines I've tested this application on so far. Is this so in general, or are there chances that scrolling the reportViewer with a wheel mouse could be brought to life?
Thanks for your helpful support! Best regards, Heinz
|
|
 | | From: | Michael Nuwer [dBVIPS] | | Subject: | Re: How to refer to report params | | Date: | Thu, 06 Jan 2005 22:39:12 -0500 |
|
|
 | Heinz Kesting wrote: > Hi Michael, > I'd never understood what the property "ref" of a ReportViewer is good for > without a living example ... > At least not from reading the rather short help text. So it could save me > from the slightly strange report bootstrap code.
Yes, the OLH is not very clear about how this works, and it took me a long time to figure out what "ref" properties mean. In the case of reports and reportviewers, the ReportViewer class, the one that is placed on a form, has a "ref" property where a reference or pointer to the report object is stored. Therefore form.reportViewer.ref points to the same objects as r points to. And it means that all of the report properties are available from the form via the reportViewer object.
In addition, the report class has a "reportViewer" property where a reference or pointer back to the reportViewer object is stored. This is a bridge from inside the report back to the form (and all it's properties).
r = new PREVIEWReport() _app.aview.repView.ref = r ? r.reportViewer.parent.text // outputs this: // CalcuLab: Rechnungsarchiv - Druckansicht
> Unfortunately it works only for > r.output = 0 // sceen
The following is the code I use for the "print" pushbutton:
function PUSHPRINT_onClick local oViewer, bPrinter oViewer = form.Viewer bPrinter = oViewer.ref.printer.ChoosePrinter() if bPrinter oViewer.ref.startPage = 1 oViewer.ref.output = 1 // printer oViewer.ref.render() oViewer.ref.output = 3 // default endif return
> function AV_PB_Print_OC > if _app.printer.chooseprinter(" CalcuLab: Drucker und Druckeinstellungen > wählen") = true
Your report has already been created, so there is no need to create it again: //set procedure to preview.rep additive //r = new PREVIEWReport() //r.output = 1 // Ausgabe auf Drucker //r.pt.marginLeft = 2.105 // Linker Rand für Ausdruck //r.pt.r_titel.text = _app.aview.cTitle + " ( K O P I E )" //r.pt.datum.text = "vom " + _app.aview.cDate //r.q_pat.rowset.setrange(_app.aview.cPat) //r.q_rech.rowset.setrange(_app.aview.cRech) //_app.aview.repView.ref = r // alle Parameter an den Report übergeben //_app.aview.repview.reexecute()
_app.aview.repView.ref.startPage = 1 _app.aview.repView.ref.output = 1 // printer _app.aview.repView.ref.render() _app.aview.repView.ref.output = 3 // default
> endif
> And here's another question about the reportViewer. The wheel mouse does not > function on the reportViewer, neither on my machine nor on the machines I've > tested this application on so far. Is this so in general, or are there > chances that scrolling the reportViewer with a wheel mouse could be brought > to life?
Well, I don't know for sure, because I use a laptop that does not have a wheel mouse. But the wheel mouse doesn't work as expected with the dBASE grid, so I wouldn't be surprised that it doesn't work with the reportViewer.
You might ask Marc Van den Berghen whether he can add the reportViewer to his wheel classes: http://www.vdblogic.de/dbl/index.htm
-- Michael Nuwer http://www.nuwermj.potsdam.edu/dLearn/ http://www.nuwermj.potsdam.edu/dSamples/
"I would rather be vaguely right, than precisely wrong." -- John Maynard Keynes
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Sun, 9 Jan 2005 13:03:41 +0100 |
|
|
 | Hi Michael, Sorry for the delay of my answer, but a sudden flu had struck me down ... > Yes, the OLH is not very clear about how this works, and it took me a > long time to figure out what "ref" properties mean. In the case of > reports and reportviewers, the ReportViewer class, the one that is > placed on a form, has a "ref" property where a reference or pointer to > the report object is stored. Therefore form.reportViewer.ref points to > the same objects as r points to. And it means that all of the report > properties are available from the form via the reportViewer object. Yes, that's clear (at least for the moment ...) > In addition, the report class has a "reportViewer" property where a > reference or pointer back to the reportViewer object is stored. This is > a bridge from inside the report back to the form (and all it's > properties). That now, is new to me (although I had seen this property, but no idea how to use it), but very useful to know! And of course, it rounds the whole thing up and gives it all much more transparency.
> Your report has already been created, so there is no need to create it > again: > //set procedure to preview.rep additive > //r = new PREVIEWReport() > //r.output = 1 // Ausgabe auf Drucker > //r.pt.marginLeft = 2.105 // Linker Rand für Ausdruck > //r.pt.r_titel.text = _app.aview.cTitle + " ( K O P I E )" > //r.pt.datum.text = "vom " + _app.aview.cDate > //r.q_pat.rowset.setrange(_app.aview.cPat) > //r.q_rech.rowset.setrange(_app.aview.cRech) > //_app.aview.repView.ref = r // alle Parameter an den Report übergeben > //_app.aview.repview.reexecute() Here you can clearly see that yet I had not fully understood the mechanism. It didn't work with r.outout = 1 and so I tried adding these (unnecessary) lines again to it, only it didn't work either ...
> _app.aview.repView.ref.startPage = 1 > _app.aview.repView.ref.output = 1 // printer > _app.aview.repView.ref.render() > _app.aview.repView.ref.output = 3 // default
Now it works with this code of yours, and I do hope that I can copy this mechanism to the other procedures in my app where I used to call reports with params.
> You might ask Marc Van den Berghen whether he can add the reportViewer > to his wheel classes: Yes, only last autumn I bought his WGrid/WListbox/WEditor classes, and they work so far quite nice. There's already a mail under way ...
Once more I'd like to thank you for your patience and your very helpful support!
Best regards, Heinz
|
|
 | | From: | Michael Nuwer [dBVIPS] | | Subject: | Re: How to refer to report params | | Date: | Tue, 11 Jan 2005 07:15:40 -0500 |
|
|
 | Heinz Kesting wrote: > Hi Michael, > Sorry for the delay of my answer, but a sudden flu had struck me down ...
I hope you fell better soon. The flu bug is making its round on this side of the Atlantic too.
I am hoping to have a look at your problem later today or tonight.
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Tue, 11 Jan 2005 17:54:24 +0100 |
|
|
 | Hi Michael,
> I hope you fell better soon. The flu bug is making its round on this > side of the Atlantic too. Thanks, after three days I'm through the worst. Hope YOU will stay alright ....
> I am hoping to have a look at your problem later today or tonight. Just take your time please, it's not urgent, since my old code is working. I am only looking for a refinement. (Last night - I was actually looking for replies to my own threads - we must have had the very same thoughts, if you compare our replies to the questions in the programming NG, and then replying 2 times within 5 minutes, quite funny ...) By the way, Marc Van den Berghen has reacted unexpectedly quick - within 5 hours after sending my mail about wheel mouse functionality in the ReportViewer I had a new ReportViewer class in my mailbox, working perfectly!
Thanks to him, from here once more!
Best regards, Heinz
|
|
 | | From: | Marc VdB | | Subject: | Re: How to refer to report params | | Date: | Tue, 11 Jan 2005 18:03:39 +0100 |
|
|
 | > By the way, Marc Van den Berghen has reacted unexpectedly quick - within 5 > hours after sending my mail about wheel mouse functionality in the > ReportViewer I had a new ReportViewer class in my mailbox, working > perfectly! > > Thanks to him, from here once more!
My pleasure,
Marc VdB
-- ------ www.vdblogic.de/dbl/homee.htm ------
|
|
 | | From: | Heinz Kesting | | Subject: | Re: How to refer to report params | | Date: | Sun, 9 Jan 2005 17:34:57 +0100 |
|
|
 | Hallo Michael, I'm afraid I enjoyed success too soon. Only by now I discovered that this method is interfering with the Header- and Footerband_onRender events of the report. My old way of starting to print was to call the ReExecute() method of the ReportViewer. Your method now is rendering the report. > > _app.aview.repView.ref.startPage = 1 > > _app.aview.repView.ref.output = 1 // printer > > _app.aview.repView.ref.render() > > _app.aview.repView.ref.output = 3 // default
That works fine, the report is printed, but since it had already been rendered to the screen, now the Headerband_onRender prints the wrong subtitles for the detailbands. (FYI: This invoice report contains always only ONE page, the headerband first prints a subtitle for labour positions, after the labour pos. list the Headerband_onRender fires and prints a subtitle for material positions, before the mat. pos are listed). So I get now always the subtitles for material positions, in the wrong position, according to the changed top property
function HB_onRender this.t1.text = "verarbeitete Materialien:" this.t1.top = 0.5 return
Therefor I set up a variable to determine in the HB_onRender event the right text for the subtitle. That again works fine as long it is only rendering to the screen. I don't get it to work for printing. In the proc.prg I inserted a line to reset the counting variable to zero, but it seems as if it is not arriving in the report. Here the code from the procedures.prg
function AV_PB_Print_OC if _app.aview.repView.ref.printer.chooseprinter(" ... wählen") = true _app.aview.repView.ref.startPage = 1 _app.aview.repView.ref.sts.gr1.nCounter = 0 // the counting variable _app.aview.repView.ref.pt.marginLeft = 2.205 // Linker Rand für Ausdruck _app.aview.repView.ref.output = 1 // printer _app.aview.repView.ref.render() _app.aview.repView.ref.output = 3 // default _app.aview.repView.ref.pt.marginLeft = 0.5 // Linker Rand für Bildschirm endif
And here the excerpt from the report .... this.firstPageTemplate = this.form.pt this.form.pt.nextPageTemplate = this.form.pt this.form.pt.sf.streamSource = this.form.sts this.form.sts.rowset = this.form.q_det.rowset this.form.sts.gr1.nCounter = 0 // the counting variable .... function HB_onRender if this.parent.nCounter = 0 this.parent.nCounter = this.parent.nCounter + 1 this.t1.text = "verarbeitete Materialien:" this.t1.top = 0.5 endif return
This counting variable, named this.form.sts.gr1.nCounter is not obviously not properly refered to, I'm afraid. If I name it differently, then there's no error neither, which tells me that the report's HB_onRender does NOT work with the variable I suppose it works. Any tip for me? Why is _app.aview.repView.ref.sts.gr1.nCounter in the proc.prg not corrosponding with this.form.sts.gr1.nCounter in the report.rep ???
For nearly 2 hours I was sure I had understood ...
Thanks for helping again, Heinz
|
|
|