Alpha Video Training
Results 1 to 15 of 15

Thread: Using run time variables on actual report

  1. #1
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Using run time variables on actual report

    I am trying to develop an application for a friend who needs to print a report monthly. I generate the report using a start date and end date which are provided by asking for them at run time to limit what goes into the report each month. Is there a way to actually use the two dates provided at run time in the report itself? I can actually use the system date as the "end date" of each report but the start date only exists at run time when it is asked for.
    Thanks for any help.

  2. #2
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,803

    Default Re: Using run time variables on actual report

    You don't say if this is desktop or web. I'll assume that it's a desktop question.

    In the code where you get the start and end dates, define the variables as global as in "dim global sdate as d" if they are date variables. Then, go to your report, report properties, variables, and define the same variables as global within the report.

    When you run the script that prints the report, the date values will now be picked up by the report.
    Finian

  3. #3
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Re: Using run time variables on actual report

    Thanks Finian for such a prompt reply. It is a desktop application. I used action scripting to "Print an existing report" and as part of definition of this action I had it ask for a startdate and enddate at run time. This allowed me to filter the data for just the month that I am interested in. Not quite sure where to define the global variables although I do understand how it would then work. Again, thanks for your reply.

  4. #4
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,314

    Default Re: Using run time variables on actual report

    Hi David,
    Without knowing the specifics of the project, but based on this being a "monthly" report, I can't help
    but think the dates you want are likely to be from the previous month.

    I think you can set the report to print using the following filter
    Code:
    between(<reportdate>,date_firstdayofpreviousmonth(),date_lastdayofpreviousmonth())
    where <reportdate> is the field to be filtered. This would mean no more "need" for user intervention
    or possibility of user error as well as the potential to run the report automatically.

  5. #5
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Re: Using run time variables on actual report

    Gregg,
    It is not the start and end dates choice that I was interested in, as the action script asks the user (secretary) to give them using its pop up calendar. But as the start date and the end dates are somewhat non regular, meaning monthly, bi-monthly, 2 months etc what I wanted to do was gather whatever is placed into the scripts start and end date and actually print those two dates on the report itself. As the report is really a bill, it would allow the receivers of the bill to see what time frame they are being billed for. I like your code and have never used it before but will definately keep it in mind in the future. Thank you for your reply.

  6. #6
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,803

    Default Re: Using run time variables on actual report

    David:

    You can convert the Action Script to xbasic (do a "Save As" first to preserve the existing sccript) and then edit the xbasic. It's a little daunting at first because the script may come out with 40 or 50 lines (that's just a guess) which are Alpha's way of dealing with every conceivable circumstance in which the script might be run. In truth though, the script can be reduced greatly down to the definition of the variables and the dialog box for their entry and the "Report.print" line. You could try simply inserting the word "global" into each "Dim global start_date " line.

    However, the dates won't appear in the report until you edit the report and define the date variables as global in the report itself.
    Finian

  7. #7
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Re: Using run time variables on actual report

    Finian, that sounds great. I will try that. Thanks again.

  8. #8
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,314

    Default Re: Using run time variables on actual report

    David and Finian,

    As long as you define the global variable before running the report, you should not need to define
    the variable in the report.
    Capture.PNG

  9. #9
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,803

    Default Re: Using run time variables on actual report

    Old habits die hard! There was a time (however long ago that might have been) when I'm pretty sure it was essential to include the definition in both places. Of course, global should BE global, so that's one old habit to kill off.
    Finian

  10. #10
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Re: Using run time variables on actual report

    I have turned the action script into xbasic and see only this code :

    'Run script locally (using local variables): Monthly Patient Report
    script_play("Monthly Patient Report")

    I also defined two new variables on the report StartDate and EndDate and as part of the definition they demand I include actual date so I put in 01/01/20. When I placed these variables in the report they show up (as expected) as 01/01/20) and not the dates the are asked for in the above script. Those dates are asked for at runtime and are not available or evident in the xbasic. How do I get the created variables in the report to use the date asked for at runtime?
    david

  11. #11
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,803

    Default Re: Using run time variables on actual report

    I don't know if this will help or confuse things but download the attached file and put it in a known location. Open the Control Panel, Code Tab, right click in white space, choose import and select the text file. The file has two functions, Get2Dates and Print_Invoice1. The Get2Dates function is called from the Print_Invoice 1 function.

    You can print the report by putting the line
    PrintInvoice_1()
    into a script or as the event on a button and executing it.

    The PrintInvoice_1 function is a cut down version of something I use regularly. I use SDate and Edate for the global date variables so the report would need to conform to those names. The PrintInvoice_1 has some stuff in there to run a query before attempting to preview or print the report. You will need to change table and field references. Hopefully I've indicated all the places where you need to do that.
    Attached Files Attached Files
    Finian

  12. #12
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,621

    Default Re: Using run time variables on actual report

    You can also do this in your script that calls the report

    with global_variables()
    startdate = ctod(ui_get_date_calendar("Start Date",dtoc(date()))
    enddate = ctod(ui_get_date_calendar("End Date",dtoc(startdate))
    end with
    Last edited by MoGrace; 07-23-2019 at 02:43 PM. Reason: fix syntax errors
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  13. #13
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Re: Using run time variables on actual report

    Finian I downloaded and went over your code. I thank you for your reply but it is so far above what I can do myself that I hesitate to try to amend it in any way. Thank you very much for your earnest reply. I will continue looking.
    david

  14. #14
    Member
    Real Name
    David Gilbert
    Join Date
    Dec 2006
    Location
    Nanuet New York
    Posts
    92

    Default Re: Using run time variables on actual report

    Robin After fixing a missing right parenthesis and replacing the single quote around "end date" with a double one, this worked for me. Thank you for your effort and help.
    david

  15. #15
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,621

    Default Re: Using run time variables on actual report

    So much for my syntax checking! Glad you got it to work.

    Fixed above post...
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Report Problem (Actual Values in fields not showing)
    By JetLi in forum Alpha Five Version 11 - Desktop Applications
    Replies: 4
    Last Post: 06-19-2012, 08:21 AM
  2. looking for actual WAS running
    By programsplus in forum Web Application Server v7
    Replies: 1
    Last Post: 08-09-2006, 01:54 AM
  3. Report Date Variables in Report Heading
    By davidab in forum Alpha Five Version 6
    Replies: 4
    Last Post: 12-21-2005, 02:33 PM
  4. Report Date Variables in Report Heading
    By davidab in forum Alpha Five Version 6
    Replies: 0
    Last Post: 12-20-2005, 11:35 AM
  5. My first actual building ?
    By A4BEST in forum Alpha Five Version 6
    Replies: 2
    Last Post: 11-01-2005, 08:06 PM

Bookmarks

Posting Permissions

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