Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Location
    Charlottesville, VA
    Posts
    18

    Unhappy Unanswered: Programming Report labels - Ouch!

    Ok - this should be easy. Need to put the date range into the report header - actually, into the page header.
    I'm setting the date range for the report in code using globals called "PeriodEnd" and "PeriodStart" in a calendar form. The calendar form then passes the criteria to the final form like this:

    Dim WhereString As String
    WhereString = "([TransactionDate] >= #" & Vars.PeriodStart & "#) AND ([TransactionDate] < #" & Vars.PeriodEnd & "#)"
    DoCmd.OpenReport Vars.NextForm, Vars.FormMode, , WhereString


    Here is an example of the final result: (([TransactionDate] >= #12/30/2002#) AND ([TransactionDate] < #1/13/2003#))

    All this works fine. The problem is that the report will not take variables of any kind, even globals. So, how can I get the Date range onto each page?

    Thanks in advance!

    - John Peterson

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    try writing a function that returns the value of your variable and use the function in the report. (same work-around works for queries too).

    also make sure your var & func are in-scope at the time of the report (i.e. public in an open form or global in a module).

    izy

  3. #3
    Join Date
    Feb 2003
    Location
    Charlottesville, VA
    Posts
    18
    Thanks Izy!

    I'd forgotten about functions...

    Found another way as well - put a label in the header, then set the label.caption to the required string from VBA. Ugly, but the variables all work in VBA code. In the report itself, variables such as vars.startdate (public startdate in module vars) get automatically turned into [vars].[Startdate], which then gets interpreted as an empty parameter. Yuck

    - John Peterson
    ------------------------------------------------------------
    Originally posted by izyrider
    try writing a function that returns the value of your variable and use the function in the report. (same work-around works for queries too).

    also make sure your var & func are in-scope at the time of the report (i.e. public in an open form or global in a module).

    izy

Posting Permissions

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