Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Location
    Illinois
    Posts
    133

    Unanswered: Calculation in report problem

    In a report I have a public variable "PreviousYear" declared as currency. In the detail format sub I add an amount to that variable. I want to display the value of PreviousYear in a text field in the report footer.

    In the Format event for the Report footer I coded:
    Me!txtPreviousYearAmount = PreviousYear

    The field is empty when the report is run

    Running the report in debug shows that the variable in populated in the detail format sub but comes up null in the report footer format sub. I have used similar code in other reports with no trouble.

    Any suggestions?

    TIA
    SteveH

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    I would suggest not using a public variable.

    Is this a rolling amount? Or a static known amount when the report is opened? If it's fixed and known, you can use OpenArgs to store this value instead of a public one.

    If it's dynamic, is there a way you can calculate it using a recordset then assign it?

    Public variables scare me like Clowns do Kramer.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Apr 2002
    Location
    Illinois
    Posts
    133
    Thanks for the reply.

    I found my problem. I tried to declare the variables like:

    dim PreviousYear, CurrentYear as Currency


    This doesn't work in VBA for '97. It has to be:

    dim PreviousYear as Currency, CurrentYear as Currency

    I am still using the public variables, scarey as it may be. It works for now. Thanks for the help.
    SteveH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •