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

Filter Report using Check-Box List-Box xdlg

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

    Filter Report using Check-Box List-Box xdlg

    You create a Check-Box List-Box xdlg showing unique values from a field from a table. Your choice(s) will be stored in a variable, let's call it vchoice.

    You want to tun a report using as a filter the choice(s) in vchoice.

    How?

    My first thoughts: vchoice is a list, an array or a collection (it does not matter). I thought, the way to do this, would be to iterate over the items (choices) in that array. But before embarking on an xbasic routine to run a *for_each loop, it seemed to me that would not be the way to do it, since each pass will generate a group of records that matches each item in the array! That would result in a dozen of reports if you have a dozen of choices. Or, you could initialize another array and append more records to it in each pass, which begs another question: how to generate a report from an array?

    Maybe I am confused, but assuming that generating reports based on several choices is rather a common practice, then there must be a well defined method to pass vchoice values to the report print filter, one that is a bit simpler than what I described above. So my question is: How do you do it?

    Thanks

    #2
    Re: Filter Report using Check-Box List-Box xdlg

    I think you would only want to run your filter/query once. So that means constructing the filter first by processing your array. Come to think of it you may be able to use the array directly in the filter using either the inlist() or is_one_of() functions.
    Code:
    filter = "Is_one_of(Yourfield,thearray)"
    After a bit of testing I came up with this. Run this code in alphasports. You may need to edit the report and set 'additional fiter' to 'none' but I didn't and the code ran as I think you desire.
    Code:
    DIM SHARED vchoice as C
    DIM SHARED varC_result as C
    auto_list_vchoice = table.external_record_content_get("product","Product_Id","","")
    
    temp_count = w_count(auto_list_vchoice,crlf())
    DELETE a_vchoice
    DIM a_vchoice[temp_count] as c
    a_vchoice.initialize(auto_list_vchoice)
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("choose products",<<%dlg%
    {region}
    Type prompt here:| [.40,15vchoice^$$a_vchoice];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    
    
    vchoice2 = crlf_to_comma(vchoice)
    query.filter = "inlist2(Product_Id,"+s_quote(vchoice2)+")"
    query.order = "recno()"
    
    :Report.Preview("Product List",query.filter,query.order)
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

    Comment


      #3
      Re: Filter Report using Check-Box List-Box xdlg

      Tim:
      Thanks for the response. That's pretty much what I've tried and that's also where you get stuck: at the part where you try to pass vchoice to the filter where neither function( inlist2() , Is-One_of()) works.

      See the error message I got when I ran your code.

      By the way: the help file indicates that the result of inlist2() is C !! one would think it would be L ! Also, the help file indicates that the first parameter of this function "Value" is "The text you want to find".. it does not suggest if you could use an expression. I tried to play with it in the IW and kept getting error messages regardless whether I use a text or an expression !
      Last edited by G Gabriel; 05-11-2007, 05:19 AM.

      Comment


        #4
        Re: Filter Report using Check-Box List-Box xdlg

        g,

        I've confirmed that Tim's script runs correctly using AlphaSports. Time to show us your data and your script, so we can help you see what you're doing differently.

        -- tom

        Comment


          #5
          Re: Filter Report using Check-Box List-Box xdlg

          That's strange. I have rerun my sample in alphasports and I am getting a report of the selected products. I put a msgbox() just after the query.filter line to show me query.filter and it showed me
          Code:
          inlist2(Product_Id,"P001,P002")
          which is the same as the error message you get except for the single quotes surrounding the whole expression in the error message. BUt that could be just the error messasge quoting the error.

          I am afraid I don't know what else to suggest but post the code. However,you say that it was my code that gave you the error.
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


            #6
            Re: Filter Report using Check-Box List-Box xdlg

            Folks:
            I think I figured out what might be wrong. I must be using an older built that does not support inlist2() !!
            I am going to try a newer built and let you know.
            Thanks

            P.S.
            For those who think they are wasting their time by monitoring the board on a regular basis: you are not. See what happens when you get rusty like me? you start ask questions that otherwise you would not have asked! Can't help it though, don't have much time for the board right now.

            Comment


              #7
              Re: Filter Report using Check-Box List-Box xdlg

              Yep...that's what it was!!
              Thanks to all.

              Comment


                #8
                Re: Filter Report using Check-Box List-Box xdlg

                Not quite there yet.

                After installing the new built, the script works in Alphasports, but not in my database. Every time I run the :Report.Preview I get a message "no pages in this report", translation: alpha is not finding the chosen item(s) in that field which is not possible since these items were checked from the values in that field.

                So the question is: how come it works in Alphasports? the only difference I see is that, the field chosen in Alphasports is made up of one word while the field values in my database could be made of one or more words. To illustrate:

                Say you have a table of contacts and you want to print a report showing those who live in zip code 70012, 90121 or 65034 chances are the script will work. On the other hand if you want to show those who live in Boston, Dallas or New Orleans, it won't!

                Something happens when you convert crlf to comma or when you look for items in the comma delimited list matching values in the field.

                I modified the expression to trim the values in the field. That did not work.

                Maybe I should look for other functions or maybe the expression needs further tweaking. Any suggestions?

                Thanks

                Comment


                  #9
                  Re: Filter Report using Check-Box List-Box xdlg

                  On further testing:
                  It does not matter if the field value is made up of one word or several. I replaced the values in alphasport with values made up of several words and the script worked. I went back to my DB, deleted the script, re-wrote it exactly as it was, and now it works!! this is one of those inexplicable things in alpha, or perhaps in development in general !!

                  At any rate, the script is so slow is rather impractical. It takes over a minute to run!

                  Are there any better suggestions!
                  Thanks

                  Comment


                    #10
                    Re: Filter Report using Check-Box List-Box xdlg

                    It's difficult to optimize this since random choices are permitted. Not sure if it will help, but you might try creating a permanent index on the field you're using in the selection listbox.

                    If the display of the listbox itself is part of the slow down, consider using an ordinary browse, marking the desired records, and then querying for marked() records.

                    -- tom

                    Comment


                      #11
                      Re: Filter Report using Check-Box List-Box xdlg

                      Tom:
                      The xdlg displays fine, it's the the initialization of the report that is extremely slow, in fact you could see the number of records been processed, 102, 112, 122... at the toolbar. That's awfully slow! If you are patient enough, or if you go get a cup of coffee and come back, you will see the report exactly as you wanted it, you just have to be patient to the point of impractically!

                      I tried to put the filter in the report itself: it didn't make any difference.
                      I think the bottleneck is Inlist2() (ditto is_one_of()). I think it works the same way as "locate text" since it does not utilize a key. I guess it scans every record for the different choices you made, one record at a time!

                      That's why I was hoping for a better expression that will match your choice(s) with values in the field. I haven't scanned the entire help file yet for that illusive expression, but it seems that alpha has not come up with one yet. Don't know if I want to try to create a custom function.

                      Comment


                        #12
                        Re: Filter Report using Check-Box List-Box xdlg

                        Other ideas to try:

                        a) copy the selected records to a temp table and base your report on it, without filters at all.

                        b) mark the selected records and filter report to show only marked records.

                        I don't see unusual delay in running the script against AlphaSports. If your table is larger, or if your report is based on a complex set, using the temp table approach should speed things up a bunch.

                        --tom

                        Comment


                          #13
                          Re: Filter Report using Check-Box List-Box xdlg

                          Tom:
                          The delay comes from the fact that the table is large and the search process is not indexed. Alphasports has very few records, you won't notice any delay.

                          To copy records to a third table, you pretty much run at the same bottleneck with the exception that instead of attempting filtering for a print operation you will be filtering for a copy operation.

                          To clarify: the problem is in passing the choices you made to the report filter (or the copy operation filter). Since your choices you made are in the form of a crlf array, you need some expression either to iterate over the array, or to "flatten" the array, that would work, ideally, with an expression that relies on an index thus speeding the process. I am not aware of any expression that does that. This is the "missing link". The functions available (inlist2() and is_one_of()) are not ideal.

                          Comment


                            #14
                            Re: Filter Report using Check-Box List-Box xdlg

                            Since your choices you made are in the form of a crlf array, you need some expression either to iterate over the array, or to "flatten" the array, that would work, ideally, with an expression that relies on an index thus speeding the process.
                            A series of indexed find by keys could be easily scripted and would run quickly.

                            -- tom

                            Comment


                              #15
                              Re: Filter Report using Check-Box List-Box xdlg

                              Tom:
                              I am not sure how you would do that? The copy (actually you need to append not copy) expression will require a filter. How are you going to pass the values from the crlf array to the filter of the append expression/operation?
                              Thanks

                              Comment

                              Working...
                              X