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 with multiple parameters

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

  • Charlie Tye
    replied
    Re: Filter report with multiple parameters

    alpha will not perform as I had hoped. I have spent the last few days trying to run reports and filter them by drop down controls on a ux, and I cant find any way to do it. if one of the fields is blank the report will not show any records. I have gone through so many suggestions on here and I cannot even find how to use the xbasic code to even open a report. all I find is things like SaveAs, but not to just open it. rapid development? not quite. seems like I am not the only one looking to do this, and they have more experience than me. so discouraging

    Leave a comment:


  • J.R. Noe
    replied
    Re: Filter report with multiple parameters

    Nothing I have tried works. Hard to believe there is no way to open a report utilizing xbasic with parameters from fields on a UX, and I have been trying for a very long time. I finally gave up. If you figure it out, please let me know.

    Leave a comment:


  • Medic1196
    replied
    Re: Filter report with multiple parameters

    Ummmm...I feel like a monkey that just got handed a smart phone. lol
    I will have to google and try to absorb this information.

    Leave a comment:


  • Progytech
    replied
    Re: Filter report with multiple parameters

    Originally posted by Medic1196 View Post
    Are stored procedures created locally or on the server?
    They are created in the server. Look at your MySQL help file on google.

    I am not familiar with MySQL but here is a pseudo SQL code you can use in your Stored Procedure:
    Code:
    DECLARE @PersonnelPK INT = 10
    DECLARE @ClassName VARCHAR(20) = ''
    
    SELECT
    	s.*
    FROM
    	Students s
    WHERE
    	(s.PersonnelPK = @PersonnelPK [B][COLOR="#FF0000"]OR @PersonnelPK = 0[/COLOR][/B]) AND
    	(s.ClassName = @ClassName [B][COLOR="#FF0000"]OR @ClassName = ''[/COLOR][/B])
    The key for this SQL statement, is to test for the value of the parameters (or arguments in AA) for a default value to ignore them, I use 0 or -1 for integers or blank space '' for varchars.

    Hope this help.

    Leave a comment:


  • Medic1196
    replied
    Re: Filter report with multiple parameters

    Are stored procedures created locally or on the server?

    Leave a comment:


  • Medic1196
    replied
    Re: Filter report with multiple parameters

    I use MySQL and the reports utilize views. Guess I need to learn about stored procedures.

    Leave a comment:


  • Progytech
    replied
    Re: Filter report with multiple parameters

    Hi Travis,
    Originally posted by Medic1196 View Post
    I have that now Robin, but if one of the filters is not set the report does not show any records. If one of the parameters is blank, I want the report to run utilizing the other parameters.
    What database are you using for your report?

    The way I handle this is as follow:
    1. I use MS SQL database, so I create a Stored Procedure with the SQL statatement I need to grab all my records. I may even use a view if I want, but AA handle Stored Procedures as the source data for reports very well.
    2. Define the data for the report using this Stored Procedure and create a report argument for each parameter defined in the stored procedure.
    3. Run my report from a grid or UX dialog and pass the expected parameters values as arguments.

    The key to all this is building your Stored Procedure properly to handle empty or NULL values.

    Leave a comment:


  • Stan Mathews
    replied
    Re: Filter report with multiple parameters

    If you can use xbasic the general format is

    Code:
    query.filter = ""
    query.order = ""
    
    
    
    :Report.SaveAs("reportnameinquotes","PDF",query.filter,query.order,"",.T.)
    So you would use the procedure outlined above to create your own query.filter variable.

    Probably sloppy thinking here. You won't know if the user enters an argument until the report is called so the advice is no good.

    I think you'll have to gather the arguments via some data entry method first and then build the query.filter.
    Last edited by Stan Mathews; 02-27-2015, 11:43 AM.

    Leave a comment:


  • Charlie Tye
    replied
    Re: Filter report with multiple parameters

    I am opening a pdf report using parameters too but not all will have a parameter value. where do I put your filter?
    my first try at this was opening a pdf report using a button that called an action javascript. does the filter go where it says 'sql filter'
    my first try at this was this,
    comid = :cid AND CDate >= :argStartDate AND CDate <= :argEndDate AND PID=:argPersonnel
    OR comid = :cid AND CDate >= :argStartDate AND CDate <= :argEndDate AND :argPersonnel=""

    which will work but each time I add a parameter I have to add another OR and then cover all the different variations.
    there has got to be an easier way. if I have a dozen or so parameters, then my way would be ridiculous to use.

    Leave a comment:


  • Al Buchholz
    replied
    Re: Filter report with multiple parameters

    Originally posted by Medic1196 View Post
    Well that was like playing "Where's Waldo".....and I still never found him. I spent a lot of time searching through all that Al, but I could not find how to show all records for parameter fields which have no value.
    Travis

    The concept is that you build a filter string that contains the parameters that have values and ignore the ones that don't.

    Code:
    'so if 
    
    
    p1 = "a"
    p2 = " "
    p3 = "x"
    
    
    'the filter would be 
    
    'f1 = "a" .and. f3 = "x"
    
    'to accomplish this the code looks something like this:
    
    myfilter = ""
    
    if p1 > "" then
    myfilter = myfilter + "f1 = "+s_quote(p1) + " "
    end if
    
    if p2 > "" then
    	if myfilter > "" then
    	    myfilter = myfilter + ".and. "
    	end if
    myfilter = myfilter + " f2 = "+s_quote(p2) + " "
    end if
    
    if p3 > "" then
    	if myfilter > "" then
    	    myfilter = myfilter + ".and. "
    	end if
    myfilter = myfilter + "  f3 = "+s_quote(p3) + " "
    end if
    
    ui_msg_box("My filter " , myfilter)
    Then you can use this filter to build a query.

    The report record selection then should be set to use the currently selected records.

    What I indicated previously will help in the filter building process.

    Or as Stan has shown there are many ways to build a string that contains the filter and make the filter as efficient as possible.

    Leave a comment:


  • Stan Mathews
    replied
    Re: Filter report with multiple parameters

    Something like

    Code:
    filt_string = ""
    filt_string = filt_string+if(start_date>{} .and. end_date > {} .and. (end_date>start_date),"between(date_field,"+s_quote(start_date)+","+s_quote(end_date)+")","")
    filt_string = filt_string+if(alltrim(personnel)>""," .and. person_field = "+quote(personnel),"")
    filt_string = filt_string+if(alltrim(course)>""," .and. course_field = "+quote(course),"")
    'etcetera
    filt_string = ltrim(filt_string,".and. ")'removes leading .and. if the dates are not valid
    Last edited by Stan Mathews; 02-27-2015, 09:44 AM.

    Leave a comment:


  • Medic1196
    replied
    Re: Filter report with multiple parameters

    Well that was like playing "Where's Waldo".....and I still never found him. I spent a lot of time searching through all that Al, but I could not find how to show all records for parameter fields which have no value.

    Leave a comment:


  • Al Buchholz
    replied
    Re: Filter report with multiple parameters

    You can build a filter as a string. Then apply the string as the filter in the call to a report.

    How are your skills building strings with xbasic?

    http://wiki.alphasoftware.com/~alpha...nd+Expressions

    Here are some programming examples using xbasic..

    http://www.alphasoftware.com/alphafo...amming-Puzzles

    Leave a comment:


  • Medic1196
    replied
    Re: Filter report with multiple parameters

    That is the purpose of my question, to save hours of experimenting. I am sure someone has done this in the past, and can point me in the right direction.

    Leave a comment:


  • Foodtester
    replied
    Re: Filter report with multiple parameters

    If a dropdown filter is not set then you presumably want to see all the records in the report. So I think you will need to set a default value for each argument such that the default is a wildcard eg : "*". Not sure of the syntax so you may need to experiment a bit.

    Leave a comment:

Working...
X