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

Filtered Browse By Date Range

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

    Filtered Browse By Date Range

    A5 V5 - I've got an embedded browse on a form that contains a date field, let's call it "Transdate". I've added 2 date variable fields to the form named "StartDate" and "EndDate". I want to be able to enter a date range in the 2 variables, hit a button, and have the browse only display the records that fall within the range. How do I get this accomplished? I will also need a button to reset back to displaying all the records.

    Thanks In Advance

    MSB
    Mark Buonagurio
    New York, NY
    212-391-6500 x 15
    [/SIZE]

    #2
    Re: Filtered Browse By Date Range

    Try this

    the OnPush event for the button to find the startdate and the enddate

    Code:
    dim tbl as p
    dim qry as p
    tbl=table.current()
    query.filter="(Transdate >= Var->startdate  )  .and. (Transdate <= Var->enddate  )"
    query.order=""
    qry=tbl.query_create()
    topparent:browse1.refresh_layout()
    qry.drop()
    The OnPush event for the show all button

    Code:
    topparent.show_all()
    topparent.fetch_first()
    Tom

    Comment


      #3
      Re: Filtered Browse By Date Range

      Tom,

      It's possible his form is based on a set of tables. Mark hasn't told us whether the browse is displaying parent or child records. This could change the code requirements, right?

      Comment


        #4
        Re: Filtered Browse By Date Range

        Tom C

        You are right - the code I show in my post is based on a single table - not a set.

        The code would have to be changed if the browse is displaying child records.

        Was watching the returns last night and took a short break and replied to this post - in my haste to get back to the returns - I didn't read the post carefully. Mea culpa

        Thanks for the heads up.

        Tom B

        Comment


          #5
          Re: Filtered Browse By Date Range

          Hopefully, Mark will tell us more about his form, and the table or tables supporting it.

          -- tom

          Comment


            #6
            Re: Filtered Browse By Date Range

            You are correct Tom. There are 2 tables involved, a member table, and a transaction table. I created a set with the Member table as parent and a one to many link based on the memberID field. The form that contains the browse is based on this set. The browse contains some fields from the member table, and some from the transaction table. I hope this clarifies.

            Thanks.
            Mark Buonagurio
            New York, NY
            212-391-6500 x 15
            [/SIZE]

            Comment


              #7
              Re: Filtered Browse By Date Range

              Mark,
              Along with any info from Tom-Tom ( :) ), the easiest way I find to create filters, especially when what I try fails, is to let a genie do it for you to create the correct syntax. Using Action Scripting try the Custom Query--you may be able to just use this instead of learning xbasic....but even when using genies and Action Scripting to produce your scripts, form calling, etc., I highly recommend always checking out what was produced in xbasic to see how it is done as the sooner you are able to use a small amount of xbasic the more you will be able to modify a simple script into a more complex one that will be needed/required at some point in a database.

              Just some thoughts!
              Mike
              __________________________________________
              It is only when we forget all our learning that we begin to know.
              It's not what you look at that matters, it's what you see.
              Henry David Thoreau
              __________________________________________



              Comment


                #8
                Re: Filtered Browse By Date Range

                Here's one way to do it using Vers 9 of Alpha Five. Not sure if the queryrun() method is available in Vers 5.

                Assume form based on a set. The parent table is Members. The one to many child is Transactions. The link is on a "Member_id" field which is character data.

                Each Transaction table record has a "Trans_date" field, which is date data.

                There are two "session" level variables defined in the form layout. They are "vd_begin_date" and "vd_end_date", and they are date data, too.

                To filter the Transactions table to show only records which have Trans_date field values lying "between" the two variable dates, use this expression:


                Code:
                topparent.[COLOR="red"]queryrun[/COLOR]("between(Transactions->Trans_Date,Var->vd_begin_date,Var->vd_end_date)","","","No","Transactions",.f.)
                To see all the Transaction table records that are linked to each parent record use this expression:

                Code:
                topparent.queryrun("Transactions->Member_Id = Member_Id","","","No","Transactions",.f.)

                Comment


                  #9
                  Re: Filtered Browse By Date Range

                  Tom C

                  queryrun() was available in Version 5

                  Tom B

                  Comment


                    #10
                    Re: Filtered Browse By Date Range

                    Thanks. I'll give it a shot
                    Mark Buonagurio
                    New York, NY
                    212-391-6500 x 15
                    [/SIZE]

                    Comment


                      #11
                      Re: Filtered Browse By Date Range

                      Why does using a variable scoped as local produce an error and not work within the filter with queryrun()? See attached.
                      Mike W
                      __________________________
                      "I rebel in at least small things to express to the world that I have not completely surrendered"

                      Comment


                        #12
                        Re: Filtered Browse By Date Range

                        Tom,

                        The lines of code you sent work great. However, I needed to create a reverse set with the Transaction table as the parent to get all the records to show in the browse. When I had the Member table as the parent, the browse only displayed a single record. Any thoughts why? I've attached the database for you to take a look at.
                        Last edited by MarkB; 11-06-2008, 04:29 PM. Reason: Add attachment
                        Mark Buonagurio
                        New York, NY
                        212-391-6500 x 15
                        [/SIZE]

                        Comment


                          #13
                          Re: Filtered Browse By Date Range

                          Mark, how about marking a trail to the parts of the database you want checked. Which form is not behaving as you wished? How do you want that particular form to behave?

                          Also tell us about your set designs. I see you sometimes using Member_id, and sometimes a field called "Number". How do you want to link transactions to members?

                          Last request... can you supply dummy transaction table records? This will make things easier on us, and will avoid problems that can happen if we enter field values that conflict with your field rules simply because we don't know your design.
                          Last edited by Tom Cone Jr; 11-06-2008, 04:53 PM.

                          Comment


                            #14
                            Re: Filtered Browse By Date Range

                            Originally posted by MarkB View Post
                            When I had the Member table as the parent, the browse only displayed a single record. Any thoughts why?
                            You have two members in the memb table with "number" 115. You only have one record for "memberid" "115" in the clubexpholding table. Thus a form based on the memberdetail set with memb as the parent will show the single clubexpholding record in the embedded browse linked to both parent records. You have no "many" child records linked to any parent record so no multiple browse records are shown.
                            There can be only one.

                            Comment


                              #15
                              Re: Filtered Browse By Date Range

                              Originally posted by Mike Wilson View Post
                              Why does using a variable scoped as local produce an error and not work within the filter with queryrun()? See attached.
                              Mike, Here is my theory.

                              Lets assume you are the CEO of a multi national company. (you are aren't you?)
                              You want to find some correspondence concerning a price fixing meeting you had with one of you competitors.

                              The actions you take are like your script (date_local_var)
                              So you look up in your diary(the dialog box) to get the date of the meeting. You store that date in a spot in your mind (the local variable).
                              Next you instruct your secretary (the queryrun function) to go find all the correspondence that matches the date you are thinking of. She attempts to carry out your instruction but complains bitterly "How am I supposed to know what to look for, am I a mind reader?"

                              Revised actions as in (date_shared_var)

                              So you look up in your diary(the dialog box) to get the date of the meeting. You store that date on a postit note and stick it to your forehead. (the shared variable).
                              Next you instruct your secretary (the queryrun function) to go find all the correspondence that matches the date on the postit note. She attempts to carry out your instruction, sees the date on your forehead, and comes back with the files you need.



                              Even though the queryrun function is run from the script where the local variable also is, the function is actually doing its thing against on object outside of the script. So when the function goes and does its thing it is no longer in the same room as the local variable. The function takes all the arguments you have given it and tries to resolve them at the point where it it is doing its work, which in this case is not within the script itself.

                              You can still use a local variable but need to formulate the instruction a little different. The CEO needs to take what is stored in his mind (the local variable) and include it in the instruction to the his secretary, instead of telling the secretary where to find the date (in the variable, which in the case of the local variable she can't see).
                              Like so:
                              Code:
                              
                              records_found = topparent.queryrun([COLOR=Blue]"T_parent->P_date = " + s_quote(ctod(Var->vlocal_date))[/COLOR],"","","No","<Cross Level>",.f.)
                              or
                              records_found = topparent.queryrun([COLOR=Blue]"T_parent->P_date = " + s_quote(ctod(vlocal_date))[/COLOR],"","","No","<Cross Level>",.f.)
                              or
                              records_found = topparent.queryrun([COLOR=Blue]"T_parent->P_date = {" + vlocal_date+"}"[/COLOR],"","","No","<Cross Level>",.f.)
                              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

                              Working...
                              X