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

Selecting records between two dates

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

  • Selecting records between two dates

    I am getting an error using the following script generated via Action Scripting.
    The error is "invalid filter expression".
    Using file that contains consecutive dates from November 1, 2008 until March 1, 2009, I am hoping to select records of seven days beginning with a prompted date (varialbe vdates). I used the Action script Prompt for Date to create the variable. Thus, vdates="December 8, 2008" as an example. I then used the query "between dates" to try and select records that begin with vdates (Dec 8) and vdates+7 (Dec 14). I tried the formula date()+7 in the Code editor and got the correct result. So, I am confused as to why the Action Script generates an error. Here is the script generated by Action Scripting:
    Code:
    dim prmpt_title as c 
    dim prmpt_default as c 
    
    prmpt_title = "Select Beginning Date"
    prmpt_default = ""
    	
    vdates = ui_get_date_calendar(prmpt_title,prmpt_default)
    
    'Opens the default Form or Browse layout, displaying all, or selected records in the layout.
    query.filter = "between(Datenumber,Var->vdates,Var->vdates+7)"
    query.order = "recno()"
    'replace variables in the filter with their actual values	
    query.filter = convert_expression(query.filter,"V")
    
    'Open the default Form showing just the records that satisfy the filter
    DIM Shared varP_layout as P
    DIM enable_show_all as l 
    'The enable_show_all flag turns makes the Show-All button on the form toolbar gray.
    'This means that the user cannot turn off the base query for the form.
    enable_show_all = .f.   
    varP_layout =  a5_open_default_Form("day",query.filter,query.order,"Temporary Query","",enable_show_all)
    Thanks for looking
    "Ollie, remember how dumb I used to be? Well, I'm much better now."

    Pete

  • #2
    Re: Selecting records between two dates

    What's the data type for "Datenumber"?

    ui_get_dates_calendar() returns a CHARACTER data type result.

    Might there be a data type mismatch between Datenumber and vdates?

    Comment


    • #3
      Re: Selecting records between two dates

      Hi Tom:
      Datenumber is D as is vdate.

      Interesting, as I closed the database and then opened it again and now the selection is partially working. The query picks the correct first date, but does not pick the correct second date (first date + 7). Instead I am getting 14 days.
      the ui_get_dates_calendar() is a new one for me, so I will take a look at that.

      Oh well, I will keep working on this. Thanks for looking....

      Update: Ok, I got it to work properly. I had to use +6 from first date. Kind of dumb on my part, thinking first date + 7 is equal to a week... Too many late nights....
      Last edited by trackmanpete; 12-07-2008, 12:29 AM. Reason: found solution.
      "Ollie, remember how dumb I used to be? Well, I'm much better now."

      Pete

      Comment


      • #4
        Re: Selecting records between two dates

        I'd be interested in seeing the working script. Thanks.

        Comment


        • #5
          Re: Selecting records between two dates

          Tom:
          Here you go. There are three options (Print Today's workout, Select a Single Day, and Select a Week (week begins on Monday's).

          Code:
          'Cancel 'CanDo' event if this condition is True: 'Var->DateOptions_CANCEL_Button
          if Var->vdate="Cancel" then 
          	
          message_text = <<%str%
          Action is cancelled.
          %str%	
          ui_msg_box("Note",message_text,UI_INFORMATION_SYMBOL)
          
          cancel(.t.)
          
          end if
          
          'Create an XDialog dialog box to prompt for parameters.
          DIM SHARED vdate as C
          DIM SHARED varC_result as C
          DELETE a_vdate		
          DIM a_vdate[3] as c
          dim temp_list as c 
          temp_list = <<%list%
          Single Day
          Today	
          Week
          %list%
          
          a_vdate.initialize(temp_list)
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          Delete XdialogStyle
          dim XDialogStyle as p
          XDialogStyle.AccentColor = "White"
          XDialogStyle.Color = "#250+211+152"
          varC_result = ui_dlg_box("Select Date Type To Print",<<%dlg%
          {Windowstyle=Gradient Radial Top Middle}
          {region}
          | [%S=BLR;D="^"%.20,5vdate^<a_vdate];
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%)
          
          'Conditional code follows. Executes only if the condition expression is True.
          IF a5_eval_expression("=Var->vdate=\"Today\"") THEN 
          'Save a report, label, letter, form or browse to an Acrobat, Rich Text, HTML or Plain Text file. You can specify which records to save.
          
          query.filter = "date_is_today(Day->Datenumber)"
          query.order = "recno()"
          
          
          
          :Report.SaveAs("OneDayWorkout","PDF",query.filter,query.order,"",.T.)
          END IF
          
          'Conditional code follows. Executes only if the condition expression is True.
          IF a5_eval_expression("=Var->vdate=\"Single Day\"") THEN 
          'Create an XDialog dialog box to prompt for parameters.
          DIM SHARED vsingledate as D
          DIM SHARED varC_result as C
          vsingledate = {}
          DIM vsingledate_EmbeddedCalendar as P
          DIM vsingledate_EmbeddedCalendar.events as C = <<%str%
          function onDateSelect as v (date as d, ptr as p)
          	
          	' Generated code. Do not delete!
          	' ------------------------------------------------------------------------
          	if eval_valid("ptr.variableName") then
          		dim sv as p
          		sv = session_variables()
          		evaluate_template("sv."+ptr.variableName+" = date")
          	end if
          	' ------------------------------------------------------------------------
          end function
          
          function onDateRightClick as v (date as d, ptr as p)
          	
          	' Generated code. Do not delete!
          	' ------------------------------------------------------------------------
          	if eval_valid("ptr.variableName") then
          		dim sv as p
          		sv = session_variables()
          		evaluate_template("sv."+ptr.variableName+" = date")
          	end if
          	' ------------------------------------------------------------------------	
          end function
          
          function onMonthNavigate as v (year as n, month as n, ptr as p)
          	
          end function
          
          function onYearNavigate as v (year as n, month as n, ptr as p)
          	
          end function
          %str%
          DIM vsingledate_EmbeddedCalendar.useDropdowns as L = .T.
          
          DIM vsingledate_EmbeddedCalendar.date as D = vsingledate
          DIM vsingledate_EmbeddedCalendar.variableName as C = "vsingledate"
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          varC_result = ui_dlg_box("Select Single Date",<<%dlg%
          {region}
          | {DatePicker=40,12vsingledate_EmbeddedCalendar}{watch=vsingledate!update_vsingledate_EmbeddedCalendar};
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%,<<%code%
          if a_dlg_button = "update_vsingledate_EmbeddedCalendar" then
          	a_dlg_button = ""
          	if vsingledate <> vsingledate_EmbeddedCalendar.date then
          		vsingledate_EmbeddedCalendar.date = vsingledate
          	end if
          end if
          %code%)
          
          END IF
          
          'Conditional code follows. Executes only if the condition expression is True.
          IF a5_eval_expression("=Var->vdate=\"Single Day\"") THEN 
          'Save a report, label, letter, form or browse to an Acrobat, Rich Text, HTML or Plain Text file. You can specify which records to save.
          
          query.filter = "Day->Datenumber = Var->vsingledate"
          query.order = "recno()"
          'replace variables in the filter with their actual values	
          query.filter = convert_expression(query.filter,"V")
          
          
          
          :Report.SaveAs("OneDayWorkout","PDF",query.filter,query.order,"",.T.)
          END IF
          
          'Conditional code follows. Executes only if the condition expression is True.
          IF a5_eval_expression("=Var->vdate=\"Week\"") THEN 
          'Create an XDialog dialog box to prompt for parameters.
          DIM SHARED vweek as D
          DIM SHARED varC_result as C
          DIM vweek_EmbeddedCalendar as P
          DIM vweek_EmbeddedCalendar.startWeekOnMonday as L = .T.
          DIM vweek_EmbeddedCalendar.disabled as P
          DIM vweek_EmbeddedCalendar.disabled.weekDays as C
          DIM vweek_EmbeddedCalendar.useDropdowns as L = .T.
          DIM vweek_EmbeddedCalendar.events as C = <<%str%
          ' The variable "ptr" provides a pointer to the calendar's properties.
          ' Properties that can be set at runtime are:
          '	ptr.date					as D - the date that is currently selected.
          '	ptr.focusDate				as D - the date that currently has focus on the calendar (setting this will navigate the calendar to the date).
          '	ptr.range.useRange			as L - whether to use the range restrictions.
          '	ptr.range.startDate			as D - start date of the range.
          '	ptr.range.startDate			as D - end date of the range.
          '	ptr.range.ignoreYear		as L - whether the range should be used every year.
          '	ptr.disabled.weekDays		as C - a comma separated list of days of the week to disable. (Note: if you have set the calendar to show Monday as the first day of the week, settings ptr.disabled.weekDays = "1" would disable Monday not Sunday)
          '	ptr.disabled.dates[]		as P - a property array of dates that will be rendered as disabled.
          '					.date		as D - the date to disable.
          '					.ignoreYear	as L - whether the date should be disabled every year.
          '	ptr.flaggedDates[]			as P - a property array of dates that will be rendered as flagged in the calendar.
          '					.date		as D - the date to flag.
          '					.color		as C - the color of the flag.
          '					.ignoreYear	as L - whether the date should be flagged every year.
          function onInitialize as v (ptr as p)
          	
          end function
          function onDateSelect as v (date as d, ptr as p)
          	
          	' Generated code. Do not delete!
          	' ------------------------------------------------------------------------
          	if eval_valid("ptr.variableName") then
          		dim sv as p
          		sv = session_variables()
          		evaluate_template("sv."+ptr.variableName+" = date")
          	end if
          	' ------------------------------------------------------------------------
          end function
          function onDateRightClick as v (date as d, ptr as p)
          	
          	' Generated code. Do not delete!
          	' ------------------------------------------------------------------------
          	if eval_valid("ptr.variableName") then
          		dim sv as p
          		sv = session_variables()
          		evaluate_template("sv."+ptr.variableName+" = date")
          	end if
          	' ------------------------------------------------------------------------	
          end function
          function onMonthNavigate as v (year as n, month as n, ptr as p)
          	
          end function
          function onYearNavigate as v (year as n, month as n, ptr as p)
          	
          end function
          %str%
          DIM vweek_EmbeddedCalendar.style as P
          DIM vweek_EmbeddedCalendar.style.font as P
          DIM vweek_EmbeddedCalendar.style.font.size as N = 8
          DIM vweek_EmbeddedCalendar.style.font.bold as L
          DIM vweek_EmbeddedCalendar.style.font.italic as L
          
          DIM vweek_EmbeddedCalendar.date as D = vweek
          DIM vweek_EmbeddedCalendar.variableName as C = "vweek"
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          varC_result = ui_dlg_box("Select Week To Print",<<%dlg%
          {region}
          | {DatePicker=40,12vweek_EmbeddedCalendar}{watch=vweek!update_vweek_EmbeddedCalendar};
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%,<<%code%
          if a_dlg_button = "update_vweek_EmbeddedCalendar" then
          	a_dlg_button = ""
          	if vweek <> vweek_EmbeddedCalendar.date then
          		vweek_EmbeddedCalendar.date = vweek
          	end if
          end if
          %code%)
          
          END IF
          
          'Conditional code follows. Executes only if the condition expression is True.
          IF a5_eval_expression("=Var->vdate=\"Week\"") THEN 
          'Save a report, label, letter, form or browse to an Acrobat, Rich Text, HTML or Plain Text file. You can specify which records to save.
          
          query.filter = "between(Day->Datenumber,Var->vweek,Var->vweek+6)"
          query.order = "Day->Datenumber"
          'replace variables in the filter with their actual values	
          query.filter = convert_expression(query.filter,"V")
          
          
          
          :Report.SaveAs("DailyWorkout","PDF",query.filter,query.order,"",.T.)
          END IF
          "Ollie, remember how dumb I used to be? Well, I'm much better now."

          Pete

          Comment


          • #6
            Re: Selecting records between two dates

            Pete,
            Here's a script I use to choose between two dates...
            btw, did you get this working right?
            Don


            Code:
            'Date Created: 30-Nov-2008 08:35:04 PM
            'Last Updated: 01-Dec-2008 10:35:13 PM
            'Created By  : Don
            'Updated By  : Don
            'Create an XDialog dialog box to prompt for parameters.
            DIM SHARED vStartDate as D
            vStartDate = Date()
            DIM SHARED vEndDate as D
            vEndDate = Date()
            DIM SHARED varC_result as C
            DIM vStartDate_EmbeddedCalendar as P
            DIM vStartDate_EmbeddedCalendar.startWeekOnMonday as L
            DIM vStartDate_EmbeddedCalendar.disabled as P
            DIM vStartDate_EmbeddedCalendar.disabled.weekDays as C
            DIM vStartDate_EmbeddedCalendar.useDropdowns as L = .T.
            DIM vStartDate_EmbeddedCalendar.events as C = <<%str%
            ' The variable "ptr" provides a pointer to the calendar's properties.
            ' Properties that can be set at runtime are:
            '	ptr.date					as D - the date that is currently selected.
            '	ptr.focusDate				as D - the date that currently has focus on the calendar (setting this will navigate the calendar to the date).
            '	ptr.range.useRange			as L - whether to use the range restrictions.
            '	ptr.range.startDate			as D - start date of the range.
            '	ptr.range.startDate			as D - end date of the range.
            '	ptr.range.ignoreYear		as L - whether the range should be used every year.
            '	ptr.disabled.weekDays		as C - a comma separated list of days of the week to disable. (Note: if you have set the calendar to show Monday as the first day of the week, settings ptr.disabled.weekDays = "1" would disable Monday not Sunday)
            '	ptr.disabled.dates[]		as P - a property array of dates that will be rendered as disabled.
            '					.date		as D - the date to disable.
            '					.ignoreYear	as L - whether the date should be disabled every year.
            '	ptr.flaggedDates[]			as P - a property array of dates that will be rendered as flagged in the calendar.
            '					.date		as D - the date to flag.
            '					.color		as C - the color of the flag.
            '					.ignoreYear	as L - whether the date should be flagged every year.
            function onInitialize as v (ptr as p)
            	
            end function
            function onDateSelect as v (date as d, ptr as p)
            	
            	' Generated code. Do not delete!
            	' ------------------------------------------------------------------------
            	if eval_valid("ptr.variableName") then
            		dim sv as p
            		sv = session_variables()
            		evaluate_template("sv."+ptr.variableName+" = date")
            	end if
            	' ------------------------------------------------------------------------
            end function
            function onDateRightClick as v (date as d, ptr as p)
            	
            	' Generated code. Do not delete!
            	' ------------------------------------------------------------------------
            	if eval_valid("ptr.variableName") then
            		dim sv as p
            		sv = session_variables()
            		evaluate_template("sv."+ptr.variableName+" = date")
            	end if
            	' ------------------------------------------------------------------------	
            end function
            function onMonthNavigate as v (year as n, month as n, ptr as p)
            	
            end function
            function onYearNavigate as v (year as n, month as n, ptr as p)
            	
            end function
            %str%
            DIM vStartDate_EmbeddedCalendar.theme as C = "Metal"
            DIM vStartDate_EmbeddedCalendar.style as P
            DIM vStartDate_EmbeddedCalendar.style.font as P
            DIM vStartDate_EmbeddedCalendar.style.font.size as N = 8
            DIM vStartDate_EmbeddedCalendar.style.font.bold as L
            DIM vStartDate_EmbeddedCalendar.style.font.italic as L
            
            DIM vStartDate_EmbeddedCalendar.date as D = vStartDate
            DIM vStartDate_EmbeddedCalendar.variableName as C = "vStartDate"
            DIM vEndDate_EmbeddedCalendar as P
            DIM vEndDate_EmbeddedCalendar.events as C = <<%str%
            function onDateSelect as v (date as d, ptr as p)
            	
            	' Generated code. Do not delete!
            	' ------------------------------------------------------------------------
            	if eval_valid("ptr.variableName") then
            		dim sv as p
            		sv = session_variables()
            		evaluate_template("sv."+ptr.variableName+" = date")
            	end if
            	' ------------------------------------------------------------------------
            end function
            
            function onDateRightClick as v (date as d, ptr as p)
            	
            	' Generated code. Do not delete!
            	' ------------------------------------------------------------------------
            	if eval_valid("ptr.variableName") then
            		dim sv as p
            		sv = session_variables()
            		evaluate_template("sv."+ptr.variableName+" = date")
            	end if
            	' ------------------------------------------------------------------------	
            end function
            
            function onMonthNavigate as v (year as n, month as n, ptr as p)
            	
            end function
            
            function onYearNavigate as v (year as n, month as n, ptr as p)
            	
            end function
            %str%
            DIM vEndDate_EmbeddedCalendar.useDropdowns as L = .T.
            
            DIM vEndDate_EmbeddedCalendar.date as D = vEndDate
            DIM vEndDate_EmbeddedCalendar.variableName as C = "vEndDate"
            ok_button_label = "&OK"
            cancel_button_label = "&Cancel"
            Delete XdialogStyle
            dim XDialogStyle as p
            XDialogStyle.AccentColor = "Gray-80"
            XDialogStyle.Color = "#159+156+146"
            varC_result = ui_dlg_box("Filter by Date..",<<%dlg%
            {Windowstyle=Gradient Horizontal Metal}
            {region}
            {Region};
            {Endregion};
            {Region}{font=tahoma,13,b}{color=white}
               Choose a Start  Date;
             {DatePicker=45,16vStartDate_EmbeddedCalendar}{watch=vStartDate!update_vStartDate_EmbeddedCalendar} ;{lf};
            {Endregion} | 
            {Region}{font=tahoma,13,b}
               Choose an End  Date;
             {DatePicker=45,16vEndDate_EmbeddedCalendar}{watch=vEndDate!update_vEndDate_EmbeddedCalendar} ;{lf};
            {Endregion}; 
            {region}{font=tahoma,12}{color=Olove Green};
                        <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>         
            {endregion}
            {endregion};
            %dlg%,<<%code%
            if a_dlg_button = "update_vStartDate_EmbeddedCalendar" then
            	a_dlg_button = ""
            	if vStartDate <> vStartDate_EmbeddedCalendar.date then
            		vStartDate_EmbeddedCalendar.date = vStartDate
            	end if
            end if
            
            if a_dlg_button = "update_vEndDate_EmbeddedCalendar" then
            	a_dlg_button = ""
            	if vEndDate <> vEndDate_EmbeddedCalendar.date then
            		vEndDate_EmbeddedCalendar.date = vEndDate
            	end if
            end if
            %code%)

            Comment


            • #7
              Re: Selecting records between two dates

              Yes, my Action Script coding does work with one caveat. When I try to do a week selection (today plus six days), the first time I try it, the code does not work. I have to use a different date than today. Once I have chosen a different date, which works, I can then go back to running the code using today's date.

              Thanks for your code submission. It will take me some time to see how it would work. I am able to get the two calendars, but have to figure out how to connect to my file.

              Thanks again for your interest.
              "Ollie, remember how dumb I used to be? Well, I'm much better now."

              Pete

              Comment


              • #8
                Re: Selecting records between two dates

                Pete,
                You might want to try setting the date variables to todays date after you dim them... that is, after:
                DIM SHARED vSingleDate as D
                vSingleDate = Date()
                and..
                DIM SHARED vWeek as D
                vWeek = Date()


                Just a thought.

                Don

                Comment


                • #9
                  Re: Selecting records between two dates

                  Don:
                  Thanks for the suggestion. I tried it and it seems to work. I will find out for sure tomorrow when the date changes. Since I tried to strictly use Action Scripting, the opportunity to create the vDate=Date() doesn't seem to exist. I did go in and change the Action Script to xbasic and implemented your code suggestion.

                  Thanks again.
                  "Ollie, remember how dumb I used to be? Well, I'm much better now."

                  Pete

                  Comment


                  • #10
                    Re: Selecting records between two dates

                    Pete,
                    You're right.. I thought you were using xbasic code. If you want to stick strictly with action scripting, I think you can still set a "default value" by checking that box and setting that value as Date().

                    Don

                    Comment


                    • #11
                      Re: Selecting records between two dates

                      Thanks, I got that to work also. I forgot about the default setting (actually I did not realize that is what it was for). One more question before I overuse your kind suggestions:
                      Rather than use your two calendars as the start point and end point for selecting between dates, I am presently using a fixed 6 days:
                      Code:
                      IF a5_eval_expression("=Var->vdate=\"Week\"") THEN 
                      'Save a report, label, letter, form or browse to an Acrobat, Rich Text, HTML or Plain Text file. You can specify which records to save.
                      
                      query.filter = "between(Day->Datenumber,Var->vweek,Var->vweek+6)"
                      query.order = "Day->Datenumber"
                      'replace variables in the filter with their actual values	
                      query.filter = convert_expression(query.filter,"V")
                      What I would like to do is create another variable that would replace the
                      "6" with whatever number I want to add from the beginning date.
                      I tried using Action Script's "Prompt for a number", but got an error message saying the variable was not correct. I thought that the variable should be a number, since the six is a number and when added to the initial date, comes up with the end date. So, I dim vnofdays as N. Then I tried it by dimming nnofdays as C. Also no luck. Any idea of what I might be going wrong with my thinking.

                      When I used the Action Scripting for "Prompt for number" I got the following code:
                      Code:
                      dim prmpt_title as c 
                      dim prmpt_prompt as c 
                      dim prmpt_default as c 
                      
                      prmpt_title = "Select # of Days to Print"
                      prmpt_prompt = ""
                      prmpt_default = "6"
                      
                      DIM SHARED vnodays AS C
                      	
                      vnodays = ui_get_number(prmpt_title,prmpt_prompt,prmpt_default)
                      	
                      
                      query.filter = "between(Day->Datenumber,Var->vweek,Var->vweek+Var->nofdays)"
                      query.order = "Day->Datenumber"
                      'replace variables in the filter with their actual values	
                      query.filter = convert_expression(query.filter,"V")
                      What confuses me is why when I prompt for a number the code creates a variable that is a character and not a number. The end result is I get an error message no matter what I try and do.
                      "Ollie, remember how dumb I used to be? Well, I'm much better now."

                      Pete

                      Comment


                      • #12
                        Re: Selecting records between two dates

                        Pete,
                        I looked it over very quickly and saw that you are dimming:
                        "dim prmpt_default as c" as a character...

                        did you want that to be a number:

                        "dim prmpt_default as N"

                        If that doesn't work let me know and I'll give it a closer look. It's my pleasure to help.. It's also my turn to give back a little.

                        Don
                        LATER:
                        OK.. didn't work... let me take a closer look and I'll get back to you.
                        Last edited by djldc; 12-09-2008, 11:45 PM. Reason: UPDATE!

                        Comment


                        • #13
                          Re: Selecting records between two dates

                          ui_get_number() returns a character string. Use val() to get a numeric result.

                          Doesn't matter how you dim the variable.
                          There can be only one.

                          Comment


                          • #14
                            Re: Selecting records between two dates

                            Pete,
                            Another thought.. replace this with yours (I change this: val(Var->nofdays))

                            query.filter = "between(Day->Datenumber,Var->vweek,Var->vweek+ val(Var->nofdays))"

                            If that doesn't work could you supply the full script in it's entirty?

                            Don

                            Comment


                            • #15
                              Re: Selecting records between two dates

                              Using Action Scripting, this is what finally worked:

                              Code:
                              'Create an XDialog dialog box to prompt for parameters.
                              DIM SHARED vnodays as N
                              DIM SHARED varC_result as C
                              vnodays = 6
                              ok_button_label = "&OK"
                              cancel_button_label = "&Cancel"
                              varC_result = ui_dlg_box("Select # of days to Print",<<%dlg%
                              {region}
                              | [%z;s1,31%.40vnodays];
                              {endregion};
                              {line=1,0};
                              {region}
                              <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                              {endregion};
                              %dlg%)
                              
                              	
                              	
                              
                              query.filter = "between(Day->Datenumber,Var->vweek,Var->vweek+vnodays)"
                              
                              query.order = "Day->Datenumber"
                              'replace variables in the filter with their actual values	
                              query.filter = convert_expression(query.filter,"V")
                              Seems as if the Action Script for "Prompt for Number" doesn't work correctly.
                              "Ollie, remember how dumb I used to be? Well, I'm much better now."

                              Pete

                              Comment

                              Working...
                              X