Alpha Video Training
Results 1 to 8 of 8

Thread: Help needed creating query filter

  1. #1
    Member
    Real Name
    Patrick Buono
    Join Date
    Apr 2000
    Posts
    69

    Default Help needed creating query filter

    I need help in creating a query.filter for a report using xdialog combo box and multi-select list.

    I can get the report to run with just the multi-select list but when I add the combo box I get different results. For instance if I select a value in the combo box and one value from the multi-select it works. But if I select a value from the combo box and many from the multi-select I get the report filtered just on the values of the multi select and the value from the combo box ist ignored.

    Any help or examples would be appreciated.

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Help needed creating query filter

    Quote Originally Posted by sicomputerguy View Post
    But if I select a value from the combo box and many from the multi-select I get the report filtered just on the values of the multi select and the value from the combo box ist ignored.
    Maybe and maybe not. What you are probably getting with one selection from each is

    this .and. that

    The multi select is likely designed to accomodate multiple logical or possibilities? It likely adds conditions something like

    this .and. that .or. something .or. yet_another

    What you need is

    this .and. (that .or. something .or. yet_another)

    The first or example is effectively evaluated as

    (this .and. that) .or. something .or. yet_another

    which yields a logical true for the

    something .or. yet_another

    without regard to the this.

    Sorry if the explanation is vague but it just means that you need to enclose the selections from the multiselect in parentheses, even if there is only one.


    this .and. (that)

  3. #3
    Member
    Real Name
    Bob Arbuthnot
    Join Date
    Apr 2005
    Location
    Belleville, KS
    Posts
    598

    Default Re: Help needed creating query filter

    Hi Patrick,

    You'll probably need to at least post your filter and what the variable names represent to get any kind of meaningful help. Otherwise any suggestions you get will just be speculation. On the other hand, if you post your filter(s) someone will more than likely tell you exactly how to change it to make it work the way you want.

    Bob Arbuthnot

  4. #4
    Member
    Real Name
    Patrick Buono
    Join Date
    Apr 2000
    Posts
    69

    Default Re: Help needed creating query filter

    Ok, here is query part of the code:



    '-------------------------------------------------------------------------------


    DIM SHARED a_selected[100] as C
    DIM SHARED varC_result as C

    multi_list =vmember
    filter = alltrim(multi_list)
    filter = *for_each(x,"Member = " + quote(x), filter)
    filter = alltrim(filter)
    filter = stritran(filter,crlf()," .or. ")
    filter = filter +".and.Grade = Var->vGrade"

    '-------------------------------------------------------------------------------




    'Print a report, label, letter, form or browse layout. You can specify which records to print.

    query.filter = filter
    query.order = "recno()"
    'replace variables in the filter with their actual values
    query.filter = convert_expression(query.filter,"V")



    'Prompt user whether to print, or preview the layout. Set default to Print
    prompt_result = ui_get_print_or_preview("Print")
    If prompt_result = "Print" then

    :Report.Print("ChildrenGradeList",query.filter,query.order)

    Else if prompt_result = "Preview" then
    :Report.Preview("ChildrenGradeList",query.filter,query.order)
    End if
    '-----------------------------------------------------------------------

    Thanks

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Help needed creating query filter

    Try changing this

    filter = filter +".and.Grade = Var->vGrade"

    to

    filter = "("+filter +") .and. Grade = "+quote(Var->vGrade)

    assuming vGrade is a character variable.

    filter = "("+filter +") .and. Grade = "+Var->vGrade

    if vGrade is a numeric variable.

  6. #6
    Member
    Real Name
    Patrick Buono
    Join Date
    Apr 2000
    Posts
    69

    Default Re: Help needed creating query filter

    Stan,

    That worked!!!

    Is there somewhere in the help file where I can find an explaination for this?


    Thanks,
    Pat

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Help needed creating query filter

    Quote Originally Posted by sicomputerguy View Post
    Stan,

    That worked!!!

    Is there somewhere in the help file where I can find an explaination for this?


    Thanks,
    Pat
    You could look at the documentation of ".or." but you have to understand how multiple combinations are evaluated, as I tried to indicate in my first answer. There is also a section on Operator Precedence.

    Your query filter was constructing expressions like

    "Member = 'A' .and. Grade = 'B'" - for single choices from each group, which was fine.

    "Member = 'A' .or Member = 'C' .and. Grade = 'B'" - for multiple choices from the multiselect, which is ambiguous and will be interpreted per the precedence rules.

    What you wanted was

    "(Member = 'A' .or Member = 'C') .and. Grade = 'B'"

  8. #8
    Member
    Real Name
    Patrick Buono
    Join Date
    Apr 2000
    Posts
    69

    Default Re: Help needed creating query filter

    I had tried with the parentheses around the Grade but I didn't think to put it around the filter.

    Thanks again for your help,

    Pat

Similar Threads

  1. Creating a filter
    By GregOnline in forum Alpha Five Version 6
    Replies: 4
    Last Post: 10-20-2005, 04:29 PM
  2. Help needed by creating Form
    By Maurice van 't Loo in forum Alpha Five Version 5
    Replies: 7
    Last Post: 02-29-2004, 12:33 AM
  3. Show All Filter Help Needed
    By Alan Lucas in forum Alpha Five Version 5
    Replies: 6
    Last Post: 06-05-2003, 08:08 AM
  4. Query Help Needed
    By dtheo in forum Alpha Five Version 5
    Replies: 9
    Last Post: 06-02-2003, 05:02 AM
  5. Query filter help needed
    By tlyon in forum Alpha Five Version 4
    Replies: 16
    Last Post: 05-20-2002, 04:06 AM

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
  •