OnInitReport doesn't work as expected

wicwic Member Posts: 96
hi all,
I'm working on a 5.00 (6.00.32012) in a classic env.
The OnInitReport() doesn't work as expected because it's triggering only the first time I run it after a save&compile.

Explanation: I set the number of copies that (should) appears on the request form in my OnInit trigger.
REPORT - OnInitReport()
NoOfCopies=5

then I save/compile and run the report. The RequestForm shows NoOfCopies = 5
I modify this value to 0 and esc the report.
Run the report again, the value of NoOfCopies = 0 ](*,) where is my 5?
are ZUP informations loaded AFTER the Init?
If I design the report, save&compile, run, then it works!

I'm very :?
#### Only one can survive ######

Answers

  • BeliasBelias Member Posts: 2,998
    I usually program this kind of things in the onopenform of the requestpage, and works like a charm...
    Anyway, if the onopenform method works (as i expect), i am still curious about the fact that the oninit doesn't work...maybe, as you said, it is overwritten by the setting of the property "savevalues" of the requestform (that are saved in the zup file).
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • vaprogvaprog Member Posts: 1,139
    Belias wrote:
    ...maybe, as you said, it is overwritten by the setting of the property "savevalues" of the requestform (that are saved in the zup file).

    Doing it in OnOpenForm or probably also on OnInit of the Form does not run when you run the form without Requestform.
    The settings in the zup will be loded related to the form.
    So, you might have to initialize it twice, one time in OnInitReport and another time in OnOpenForm (or in OnInit of the form, depending on what you want to get).
  • BeliasBelias Member Posts: 2,998
    vaprog wrote:
    Doing it in OnOpenForm or probably also on OnInit of the Form does not run when you run the form without Requestform.
    oh, sure...
    and if oninitform doesn't work, go for the onopenpage and onprereport triggers, it should be fine (depending on where you placed the rest of your code...i don't know if you have some fancy logic in the oninit :mrgreen: )
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • wicwic Member Posts: 96
    Hi all,
    NUmberofCopies is a field on the RequestForm, but it's set on the OnInit() trigger to 5 because it's desired so. #-o

    In short: the problem comes form the property "SaveValues" of the RequestForm. This property has "priority" over the OnInit, or this part of functionality runs after the OnInit().
    I understand this as:
    1° Execute the OnInit trigger, (here I set my GlobalVar NumberOfCopies to 5)
    2° Take the value saved last time (maybe from zup)
    The second step has for effect to set NumberOfCopies back to the latest value. The first time I use it - after a save&Compile - it's null so it doesn't reset my value of 5 put by code.
    Let's say I run the report... I overwrite manually the 5 by a 2, the system saves this 2 as default. So never again the 5 set by code will be used because the latest saved value is 2 so it has priority.
    Solution: set property "SaveValues" to NO!
    \:D/
    Regards

    noteToWebmasters:how do I put this post as "SOLVED"?
    #### Only one can survive ######
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    wic wrote:
    noteToWebmasters:how do I put this post as "SOLVED"?
    Edit your first message again, and look at the field Attribute.
  • krikikriki Member, Moderator Posts: 9,110
    Some clarification on "OnInitReport".

    It is triggered when the report is initialized.
    So when you do a REPORT.RUN[MODAL], it is triggered at that moment and each time you run the line of code.

    If you have a report-variable, the first time you run the report, it OnInitReport-trigger is run but not the next times. At least until you 'destroy' the variable by closing the form (run by NOT using a form-variable!) or using CLEAR of the report.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.