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

xdialog date range on embedded browse

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

    xdialog date range on embedded browse

    I am trying to arrange a search on an embedded browse on a form. I want the browse to show the records that fall between two dates on the browse
    I have a button that initiates an xdialog where the dates can be written or selected in the calendar on the field style.
    I then try to use the variables to do a query on the table that the browse is based on. I suppose that this will then be reflected in the browse but
    I haven't gotten that far yet.
    I am trying to use the code I see in the help files on Between_Date() The code there seems to be pretty clear but when I run their code it gets stuck
    on the line that creates the query. I always get an error message that says no such field exists so I guess I haven't declared the variables adequately?
    can anyone show me how I can properly get this to work. I need to be able to locate a file on a browse that falls between two dates.
    any insight would be greatly appreciated as I have never really figured out how I can use xdialog to do anything outside of the dialog. I can't really see how to get things in and out of a x-dialog. I have looked at the alpha Sports example but it deals with reports and what I am interested in is a browse in a form.
    Thanks
    below is the code I am trying to use what I get when I run this code is error message.png


    Code:
    'Date Created: 06-Mar-2014 05:35:57 PM
    'Last Updated: 13-Mar-2014 07:27:21 AM
    'Created By  : Assistant
    'Updated By  : Assistant
    'Create an XDialog dialog box to prompt for parameters.
    
    DIM Global VFirst_Date as D
    DIM Global VLast_Date as D
    DIM Global varC_result as C
    Dim t as P
    Dim i as P
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Search  Records For Dates in a Range",<<%dlg%
    {region}
    First Date in Range:| [%DATE;P=popup.calendar(dtoc(V_First_date));I=popup.calendar%.40V_First_date!V_First_date_*];
    Last Date in Range:| [%DATE;P=popup.calendar(dtoc(VLast_Date));I=popup.calendar%.40VLast_Date!VLast_Date_*];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%,<<%code%
    if left(a_dlg_button,13) = "VFirst_Date_" then 
    	if a_dlg_button = "VFirst_Date_killfocus" then 
    		V_First_date = ctod(dtoc(VFirst_Date))
    	end if 
    	a_dlg_button = ""
    end if 
    
    if left(a_dlg_button,11) = "VLast_Date_" then 
    	if a_dlg_button = "VLast_Date_killfocus" then 
    		VLast_Date = ctod(dtoc(VLast_Date))
    	end if 
    	a_dlg_button = ""
    end if
    %code%)
    t=table.open("discovery")
    query.filter=between_date("date",VFirst_Date,VLast_Date)
    i=t.query_create()

    #2
    Re: xdialog date range on embedded browse

    query.filter=between_date("date",VFirst_Date,VLast_Date)

    The name of the field in the discovery table which you want to query for being between VFirst_Date and VLast_Date is date?
    There can be only one.

    Comment


      #3
      Re: xdialog date range on embedded browse

      Stan
      Wow! Talk about a quick response you caught that.
      This is an oversight it should read query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
      "Document_Date is a date field. Correcting this I now get an error message telling me that i=t.query_create() is an incorrect data type.
      I am a bit baffeled there must be some other error I have made.
      Thanks for your help. Mind you I am taking this more or less right out of the help file which is why I made that oversight.

      Comment


        #4
        Re: xdialog date range on embedded browse

        First Date in Range:| [%DATE;P=popup.calendar(dtoc(V_First_date));I=popup.calendar%.40V_First_date!V_First_date_*];
        VFirst_date

        or

        V_First_date

        ???

        Comment


          #5
          Re: xdialog date range on embedded browse

          Tom
          Thanks so much! That's obviously sloppy I guess I need code glasses. I re did the dialogue and attached the code to a button Now when I run the code I don't get any error messages but nothing happens to my browse either or my table. I am not really doing anything to order the table. It needs more work. My code doesn't go anywhere that I can tell. I need some other way to get at the browse on my form with this dialog.


          'Date Created: 14-Mar-2014 10:49:11 AM
          'Last Updated: 14-Mar-2014 10:49:11 AM
          'Created By : Assistant
          'Updated By : Assistant
          ''Create an XDialog dialog box to prompt for parameters.
          DIM SHARED VFirst_Date as D
          DIM SHARED VLast_Date as D
          DIM SHARED varC_result as C
          Dim SHARED t as P
          Dim SHARED i as P
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          varC_result = ui_dlg_box("Show records between a range of dates.",<<%dlg%
          {region}
          Enter Beginning Date:| [%DATE;P=popup.calendar(dtoc(VFirst_Date));I=popup.calendar%.40VFirst_Date!VFirst_Date_*];
          Enter ending Date:| [%DATE;P=popup.calendar(dtoc(VLast_Date));I=popup.calendar%.40VLast_Date!VLast_Date_*];
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%,<<%code%
          if left(a_dlg_button,12) = "VFirst_Date_" then
          if a_dlg_button = "VFirst_Date_killfocus" then
          VFirst_Date = ctod(dtoc(VFirst_Date))
          end if
          a_dlg_button = ""
          end if

          if left(a_dlg_button,11) = "VLast_Date_" then
          if a_dlg_button = "VLast_Date_killfocus" then
          VLast_Date = ctod(dtoc(VLast_Date))
          end if
          a_dlg_button = ""
          end if
          %code%)
          t=table.open("discovery")
          query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
          i=t.query_create()

          Comment


            #6
            Re: xdialog date range on embedded browse

            Code:
            t=table.open("discovery")
            query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
            i=t.query_create() 
            t.close()
            if I > 0
            browse.viewQueried("asavedbrowsename",query.filter)
            'or
            'a5_open_default_Browse("buyer",query.filter,"","Temporary Query","",enable_show_all)
            end if
            There can be only one.

            Comment


              #7
              Re: xdialog date range on embedded browse

              George,

              tell us about your form.

              based on a set of tables, or just one table?

              what's the name of the table supporting the embedded browse you mention? Is it "discovery"?

              if your form is set based describe the members of the set and tell us how they're linked.

              In its present form, your script, (and stan's) will open a new instance of the discovery table, without changing the range of records displayed in your embedded browse.

              Comment


                #8
                Re: xdialog date range on embedded browse

                Tom
                I have just one table called "discovery" the form name is also called "discovery" and the embedded browse based on the table
                has an object name of "CONTROL_BROWSE1"
                on the table I have a variety of fields for each record one of which is "Document_Date"
                so I wanted to get a view of certain records between certain dates.
                This is really a common search criteria and I wanted to see how to do this
                I started by looking at all kinds of seach functions and dialogs and it seemed reasonable
                to try and get it to work from a x-dialog. But I have never worked much with x other than
                to modify alfpha's progressive lookup for many other kinds of fields but I didn't seem to get it to work for dates.
                I have tried to apply Stans script
                I tried both of the methods but I get errors in the code. He gives me two approaches which I have tried
                first I tried

                t=table.open("discovery")
                query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
                i=t.query_create()
                t.close()
                if I > 0
                browse.viewQueried("Documents_Browse",query.filter)
                'or
                'a5_open_default_Browse("buyer",query.filter,"","Temporary Query","",enable_show_all)
                end if
                this didn't work because of the "if I>0" clause. the error said something about the variable was of the wrong type so I didn't know where that came from anyway so I got rid of the if clause
                I suppose it is some kind of error code.
                When I did this and ran the code, a new window popped up with the range of dates in the new browse "Documents_Browse". So great!
                at least I am getting something of the answer.
                I would have preferred the embedded browse on the form to show the changes but I don't see a function or method to do this.
                my form object under properties is named "CONTROL_BROWSE1" the form is also called "Discovery"
                anyway at least this gives a browse view of what I am looking for so that is great!
                I really appreciate this, thanks so much to you and Stan. I still don't know how to make it reveal this in the embedded form.
                However, I think this will work for me if I can't see how to do it.
                Here is the code that seems to work.
                'Date Created: 14-Mar-2014 10:49:11 AM
                'Last Updated: 14-Mar-2014 03:08:08 PM
                'Created By : Assistant
                'Updated By : Assistant
                ''Create an XDialog dialog box to prompt for parameters.
                DIM SHARED VFirst_Date as D
                DIM SHARED VLast_Date as D
                DIM SHARED varC_result as C
                Dim SHARED t as P
                Dim SHARED i as P
                ok_button_label = "&OK"
                cancel_button_label = "&Cancel"
                varC_result = ui_dlg_box("Show records between a range of dates.",<<%dlg%
                {region}
                Enter Beginning Date:| [%DATE;P=popup.calendar(dtoc(VFirst_Date));I=popup.calendar%.40VFirst_Date!VFirst_Date_*];
                Enter ending Date:| [%DATE;P=popup.calendar(dtoc(VLast_Date));I=popup.calendar%.40VLast_Date!VLast_Date_*];
                {endregion};
                {line=1,0};
                {region}
                <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                {endregion};
                %dlg%,<<%code%
                if left(a_dlg_button,12) = "VFirst_Date_" then
                if a_dlg_button = "VFirst_Date_killfocus" then
                VFirst_Date = ctod(dtoc(VFirst_Date))
                end if
                a_dlg_button = ""
                end if

                if left(a_dlg_button,11) = "VLast_Date_" then
                if a_dlg_button = "VLast_Date_killfocus" then
                VLast_Date = ctod(dtoc(VLast_Date))
                end if
                a_dlg_button = ""
                end if
                %code%)
                t=table.open("discovery")
                query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
                i=t.query_create()
                t.close()
                browse.viewQueried("Documents_Browse",query.filter)
                'or
                'a5_open_default_Browse("discovery",query.filter,"","Temporary Query","",enable_show_all)
                I tried the other method of code but I had a problem with the "enable_show_all"
                seems the computer sees this as some kind of variable not found.

                Comment


                  #9
                  Re: xdialog date range on embedded browse

                  Sorry, I intended to post

                  t=table.open("discovery")
                  query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
                  i=t.query_create()
                  recs = i.records_get()
                  t.close()
                  if recs > 0 'only proceed if there are records that fit the query
                  browse.viewQueried("Documents_Browse",query.filter)
                  'or
                  'a5_open_default_Browse("buyer",query.filter,"","Temporary Query","",enable_show_all)
                  end if


                  And the enable_show_all is from the documentation but they pass that variable to the function so in this usage it should be

                  a5_open_default_Browse("buyer",query.filter,"","Temporary Query","",.T.)

                  or .F. to your preference.

                  If you want to filter the form you have open, based on the discovery table, you could.

                  t=table.current() 'don't need to open an open table
                  query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
                  i=t.query_create()
                  recs = i.records_get()
                  t.close()
                  if recs > 0
                  parentform.queryrun(query.filter)
                  end if
                  There can be only one.

                  Comment


                    #10
                    Re: xdialog date range on embedded browse

                    Stan Wow!
                    Thanks So Much!
                    This is working on the embedded browse in my form.

                    t=table.current() 'don't need to open an open table
                    query.filter=between_date("Document_Date",VFirst_Date,VLast_Date)
                    i=t.query_create()
                    recs = i.records_get()
                    t.close()
                    if recs > 0
                    parentform.queryrun(query.filter)
                    end if
                    I had to take out the "t.close" however because it told me it couldn't close the main table for the session or something
                    now it works exactly the way I imagined thanks so much you made my day! This is a big big help. GREAT!

                    Comment

                    Working...
                    X