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

Between function in a query.filter

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

    Between function in a query.filter

    Good morning to all,

    This is a script I used on a button to select records from a Table "SOUMISSIONS" and print using the report "Rapport_C".

    The variables are entered using the "MDDialog" script shown below.

    Both scripts are an adaptation from Xbasic for Everyone Chapter 38.

    I need your comments on line 25. Can I do that?

    I do not get any result but no error message.

    Thanks in advance for your usual help.

    JP

    1 ''XBasic
    2 dim fdate as d
    3 dim edate as d
    4 dim montanta as n
    5 dim montantb as n
    6 dim lastbutton as c
    7 dim SOUMISSIONS as p
    8 form.view("MDDialog","dialog")
    9 lastbutton=:MDDialog.last_pressed()
    10 if lastbutton="OK_button" then
    11 fdate=:MDDialog:Starting_date.value
    12 edate=:MDDialog:Ending_Date.value
    13 montanta=:MDDialog:valuea.value
    14 montantb=:MDDialog:valueb.value
    15 end if
    16 MDDialog.close()
    17 if lastbutton="Cancel_button" then
    18 end
    19 end if
    20 'else continue
    21 SOUMISSIONS=table.current()
    22 query.option="I"
    23 query.description="date query"
    24 query.order="DATE"
    25 query.filter="between(DATE,fdate,edate).and.between(montant,montanta,montantb)"
    26 ip=SOUMISSIONS.query_create()
    27 SOUMISSIONS.index_primary_put(ip)
    28 SOUMISSIONS.fetch_first()
    29 preview:
    30 :report.preview("Rapport_C")
    31 end


    This is the MDDIALOG script:

    ''XBasic

    dim shared starting_date as d
    dim shared ending_date as d
    dim shared valuea as n
    dim shared valueb as n

    if isblank("var->starting_date").or.isblank("var->ending_date").or.isblank("var->valuea").or.isblank("var->valueb") then
    ui_msg_box("Erreur d'entr�e","Les deux dates et les deux montants sont n�cesaires")
    end

    end if
    if ending_date

    #2
    RE: Between function in a query.filter

    JP,

    Ran something similar through the script recorder and got

    query.filter = "BETWEEN(SKU->RETAILDATE,{01/01/02},{04/01/02}).AND.BETWEEN(SKU->DEPT_CD,"01","05")"

    (all one line), so your expression should be ok.

    You might try adding the explicit var-> declaration

    query.filter="between(DATE,var->fdate,var->edate).and.between(montant,var->montanta,var->montantb)"
    There can be only one.

    Comment


      #3
      RE: Between function in a query.filter

      Thanks Stan,

      Really appreciated.
      I will check my report properties, may be there is something there that I did not see.

      Best regards

      JP

      Comment


        #4
        RE: Between function in a query.filter

        also, you are using a "reserved word" as a field name:DATE, which is recommended strongly against. You may have to experiment with something like between(filename->date,var->fdate,var->edate)
        Cole Custom Programming - Terrell, Texas
        972 524 8714
        [email protected]

        ____________________
        "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

        Comment


          #5
          RE: Between function in a query.filter

          Thanks Martin,


          May be I have been lucky, I have been using many scripts with "date" without any problem til today.

          My problem is that DATE is the field name in my table, I should probably try to be more careful and use different names for my fields.

          Thanks again for warning me.

          Best regards

          JP

          Comment


            #6
            RE: Between function in a query.filter

            I don't think this will give you what you want - at least I haven't had much luck this way. If I'm wrong, somebody please tell me!

            You are querying on the table and then running a report. This has never worked correctly for me. I find that querying a form and then running the report seems to work even if the form is closed before printing. (I sometimes open the form with form.load(), set the forms base query with Xbasic, and close the form without ever making it visible to the user.

            For instructions on setting the form's base filter, see .Query_run() under Xbasic Methods for Working with Forms and Browses. (JP, this is in my Help file.)

            Comment


              #7
              RE: Between function in a query.filter

              JP

              It seems odd that you used .and. in line 25. Are the records of interest within both date ranges? If not, they'll never show up. If you used .or. and the records were present in either range they'd be included.

              -- tom

              Comment


                #8
                RE: Between function in a query.filter

                Hi Tom,

                My scripts are written in "frenchglish" mixture of french and english

                Line 25 asks to filter between two dates and within those dates to filter again between two amounts ("montanta and montantb are quotation dollar values)

                For example I want to report all quotations between $5000.00 and $10000.00 during let say Jan 01 2001 and Hune 01 2001.

                I guess line 25 works ok.

                Thanks for your input

                Regards

                JP

                Comment


                  #9
                  RE: Between function in a query.filter

                  Thanks Cal,

                  Actually I am not querying the form, but the "Soumissions" table. What I am doing is using a Dialog form to enter the variables and then do the query and thenrun a report.

                  As mentionned previously, I have adapted Chapter 38 Example to my application.

                  I use it alresdy with success but this time I am trying to query on two fields as I mentionned to Tom.

                  I will check the Help file following yout suggestion and I will play around and let you know about the outcoming

                  Thanks and regards

                  JP

                  P.S: Your help file is very handy.

                  Comment


                    #10
                    RE: Between function in a query.filter

                    Cal,
                    I have a number of reports that require a series of queries,
                    as no one query can get the results. What I do successfully is like this:

                    t1=table.open("customers")
                    t1.unmark_range()
                    query1=.........
                    mark_range()
                    query2=...........
                    mark_range()
                    and then let the report filter be: marked()
                    what I like about marking and unmarking records is that it happens almost instantaneously - even with large (for me, maybe 25,000 records) files.
                    Cole Custom Programming - Terrell, Texas
                    972 524 8714
                    [email protected]

                    ____________________
                    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                    Comment

                    Working...
                    X