Search code examples
c#activereportsmyob

Trouble referencing labels with Active Reports


Ok, so to start off, this is my first time working with C#, and the top it off I am attempting to work with it in a report editor for MYOBs AEPM software, which doesn't exactly give me a lot of info or flexibility. What I have been able to work out is that it uses some version of Data Dynamics Active Reports, but not sure which one. I also cannot seem to figure out what naming they have used for much of the report. Anyway, back to the main issue.

I am needing to add some calculations to the report that the visual editor wont allow me to do(it is restricted to Count, Sum, Min, Max, Avg, Var, so not really helpful). Now the calculations are pretty simple(One is a total x .7, and the other being the result of the first x 74 but this value might be changed in the future). Figured the best way would be to just have 2 text boxes with a value in each of them of "0", and then just once the main report is pretty much done run the calculations and replace the values of the two text boxes. So I made the text boxes in the appropriate section and labelled them CalcTotal1 and CalcTotal2.

Now in the editor it allows me to select the object and an event to trigger it, so selected ReportFooter as the object and AfterPrint as the event. I then just put in a line to chance the CalcTotal1 value and tried to generate the report resulting in the following error:

Error Message: Report Script Compile Error on line 8 Error = The name 'CalcTotal1' does not exist in the current context

public void ReportFooter_AfterPrint()
{
    CalcTotal1.Text = "Hello";
}

I have tried looking at the documentation for Active Reports but I am not having much luck, so any ideas would be incredibly welcome.


Solution

  • The MYOB AE PM feature referred to is called Smart Reports. I was able to replicate the error and consequently resolved the problem by using the following syntax:

    ((TextBox)rpt.Sections["Detail"].Controls["TextBox2"]).Text= "$2000.00";
    

    eg:

    public void Detail_AfterPrint()
    {
    ((TextBox)rpt.Sections["Detail"].Controls["TextBox2"]).Text= "$2000.00";
    
    }