Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Print code PROBLEM!!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Print code PROBLEM!!!

    Help

    Can anyone please explain why the code below in After Validate event of a Print Dialogue drop down box would give the error statement when tried in live preview. I'm totally and utterly stumped. Tried all variations of filter expressions (Code copied from WAS demo and field names and variable names altered where appropriate) See attached document for more clarity.

    Robert

    CODE INPUT

    IF eval_valid("StatementNumber") = .f. Then
    goto skipreport
    end if
    dim filter as c
    dim order as c

    'since StatementNumber is a multi-select DropDownBox, it is actually an array that contains the selected values.
    dim statnum as c
    statnum = StatementNumber.dump()
    statnum = remove_blank_lines(statnum)
    statnum = *for_each(x,"Month_Nof = " + quote(x),statnum)
    filter = stritran(alltrim(statnum), crlf()," .or. ")
    Order = ""

    Dim filename as c
    filename = session.session_folder + chr(92) + "tempreport.pdf"
    filename = report.saveas("statement landscape","pdf",filter,order,filename,.f.)
    if file.exists(filename)
    currentform.RedirectTarget = session.session_url + "tempreport.pdf?" + rand_string(5)
    end if
    skipreport:

    ERROR OUTPUT

    Errors in: event.AfterValidate code:Invalid report filter expression: 'Month_Nof = "13" .or. Month_Nof = "14" .or. Month_Nof = "15"'.
    StatementNumber




    #2
    RE: Print code PROBLEM!!!

    Are you sure the month number should be a character value?

    The function Month(date()) returns a numeric value.

    Cal Locklin
    www.aimsdc.net

    Comment


      #3
      RE: Print code PROBLEM!!!

      Cal,

      I copied the code from the WAS demo Printdialogue component where the invoice_ number field in the base table was a character field as also specified when creating the dropdown box control.
      So I ensured that Month_Nof field in my base table was also character and also when creating the dropdown box.

      I do not see the function Month(date())used in the coding that I copied.

      I've tried using the print genie in the After Validate code creator and also the technique created by yourself published in the documentation to enter the appropriate filter code but all to no avail.

      Robert

      Comment


        #4
        RE: Print code PROBLEM!!!

        The message you are getting is saying that the filter expression is incorrect for the *report*. You should try running the report from the Interactive window with
        filter=" Month_Nof = '13' .or. Month_Nof = '14' "
        order=""

        preview_report("statement landscape",filter,order)

        See if that works. If it doesn't then you have to find out what kind of filter works properly with your report.

        Comment


          #5
          RE: Print code PROBLEM!!!

          Peter, Thank you for your response.

          I tried exactly what you said first ensuring that report was set for no filter and no additional filtering at runtime.

          Alpha returned a warning box

          Script:UI_DLG_BOX:line:1626
          Variable "a_dlg_button" not found.

          After a while Error message

          Invalid report filter expression:'Month_nof='13'.or.Monthf_nof='14"

          I checked the syntax that I typed in the interactive window and it was exactly as you suggested

          Filter="Month_nof='13'.or.Month_nof='14'"

          There is a difference in the syntax regarding the quote signs. Any significance?

          To further check the filters developed when I apply the filters using the filter builder.

          I changed the report set up to allow filter criteria at run time.

          In filter builder chose table from list - site_invoice_data
          In filter builder chose Field from list - Month_nof
          selected criteria is equal to 13 or 14

          The expression shown in filter window was
          site_invoice_data-"Month_nof="13".or.site_invoice_data-"Month_nof="14"

          The report printed as expected.

          on this basis I then tried substituting the single quotes in the expression you suggested with the double quote as above surrounding the numbers but returned invalid expression.

          How do I duplicate the expression created in the filter builder(which works) to the interactive window.

          Thank you for your suggestion and interest. I'm confused as to why such a simple task should cause so much problem after all it was just a copy and paste action from a script that worked. Really confused and frustrated.

          Regards Robert

          Comment


            #6
            RE: Print code PROBLEM!!!

            Robert

            The expression created by the expression builder leads me to believe you are filtering a report on child records in a set. In that case, you must include the table name.

            To convert the generated expression to a filter expression for the report, you can try 2 ways.

            "site_invoice_data-"Month_nof='13'.or.site_invoice_data-"Month_nof='14' "

            or

            "site_invoice_data-"Month_nof=\"13\".or.site_invoice_data-"Month_nof=\"14\""

            I prefer the second method, but sometimes it does take a little experimentation to get it right. One way to test an expression is to use the interactive window and do something like this to see how the charactrer string will be evaluated

            report_filter = "site_invoice_data-"Month_nof=\"13\".or.site_invoice_data-"Month_nof=\"14\""
            ?report_filter
            = site_invoice_data-"Month_nof="13".or.site_invoice_data-"Month_nof="14"

            Jerry

            Comment


              #7
              RE: Print code PROBLEM!!!

              Jerry,

              Yes you are correct regarding the set. The report is based on a set where the filter field (Month_nof) is in child table of the set. I will try the all the filter expressions that you suggest.

              One question - Is the -" a legitimate symbol to be used in the the synatax of the expression such as

              "site_invoice_data-"Month_nof='13'. etc

              NB in the WAS demo where I copied the code from the report was also based on a set, but was the difference there that the filter was from the parent table and therefore did not need to be so specified,

              Apologies - that was a second question not a note.

              Jerry thanks for your insight and information.

              Regards Robert

              Comment


                #8
                RE: Print code PROBLEM!!!

                Jerry,

                Carried out all the procedures as you suggested and the syntax input in the interactive window produced the same filter statement as when using the filter genie to print the report in basic A5


                site_invoice_data-"Month_nof="13".or.site_invoice_data-"Month_nof="14"

                Using this information I input the following in my original AfterValidate code when trying to develop my PrintDialogue dropdown box

                CODE INPUT

                IF eval_valid("StatementNumber") = .f. Then
                goto skipreport
                end if
                dim filter as c
                dim order as c

                'since StatementNumber is a multi-select DropDownBox, it is actually an array that contains the selected values.
                dim statnum as c
                statnum = StatementNumber.dump()
                statnum = remove_blank_lines(statnum)
                statnum = *for_each(x,"site_invoice_data-"Month_Nof = " + quote(x),statnum)
                filter = stritran(alltrim(statnum), crlf()," .or. ")
                Order = ""

                Dim filename as c
                filename = session.session_folder + chr(92) + "tempreport.pdf"
                filename = report.saveas("statement landscape","pdf",filter,order,filename,.f.)
                if file.exists(filename)
                currentform.RedirectTarget = session.session_url + "tempreport.pdf?" + rand_string(5)
                end if
                skipreport:

                ERROR OUTPUT

                Errors in: event.AfterValidate code:Invalid report filter expression: 'site_invoice_data-"Month_Nof = "13" .or. 'site_invoice_data-"Month_Nof = "14"'

                This is the exact same coding expression that works when trying to produce the report using the print genie in the basic Alpha5 desktop.

                If i was to start again from square one how do you suggest I try to resolve this issue.
                I know this must seem a bit of a pain but if I can just solve this one small issue eveything else in what I am trying to achieve will just fall into place.

                Thanks again for your advice - its all a learning experience.

                Robert

                Comment


                  #9
                  RE: Print code PROBLEM!!!

                  Robert

                  'site_invoice_data-"Month_Nof = "13" .or. 'site_invoice_data-"Month_Nof = "14"'

                  is not the same as

                  "site_invoice_data-"Month_Nof = \"13\" .or. site_invoice_data-"Month_Nof = \"14\"

                  Note the single quote before the second site_invoice_data in your expression. Getting the quotes correct is definitely the most difficult part of building an expression. I will take a look at the code you use to build the expression to see if I can find a solution, since the issue is there.

                  Jerry

                  Comment


                    #10
                    RE: Print code PROBLEM!!!

                    Jerry,

                    The second quote that you spotted was a typo on my part.

                    Robert

                    Comment


                      #11
                      RE: Print code PROBLEM!!!

                      Robert

                      I built a little test table and tried you report code outside of a web component, and the filter worked correctly. I don't know why it doesn't work in your context. Without the actual tables, it is not possible to fully test your situation.

                      Jerry

                      Comment


                        #12
                        RE: Print code PROBLEM!!!

                        For the interest of any Alpha users who were experiencing similar problems, Jerry kindly scrutinised my tables etc and noticed inconsistencies in my naming conventions, where in some cases an underscore in the name was followed by a space. This was unintentional in my part but nonethelss caused problems. Although Alpha tries to correct the error by adding a further underscore when processing reports etc. it is very unstable and as the database is developed further and new reports, filter expressions etc are added the errors etc are magnified and there seems no obvious apparent reason. Therefore as I now will be reconstructing my database from scratch I would advise all users if they dont already know - be very careful when setting up table structures and names to ensure similar problems to the one I've experienced do not occur. I would like to thank Jerry, who gave me a full and detailed explanation of the errors and consequences, and all contributors for the time help and advice given in this thread.

                        Regards Robert

                        Comment

                        Working...
                        X