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

Complex calculation for determining the value of a field

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

    Complex calculation for determining the value of a field

    I am trying to put a date in a field that is a calculation based on the values of 3 other fields. The filed name is "next_svcdate". This field is calculated by starting with the field "svcdate" and then generate a new date based on the "svctype", "week" & "dayofweek". The "svctype" contains values for Daily, Weekly, Monthly, Simi-Monthly, etc. The "week" field contins what week in the month the service should occur and the "dayofweek" determines what day (Sunday, Monday, Tuesday, etc) the service should occur on.

    So if I enter a svcdate of 1/1/13 and the service type is Monthly on the 1st week and on Tuesday, then it should calculate the "next_svcdate" to be "2/5/2013".

    I am assuming that I would have to do this as an expression in the Field Rules for the "next_svcdate" what I have that assigned as a calculated field?

    Any help or guidance would be greatly appreciated.

    #2
    Re: Complex calculation for determining the value of a field

    Week will be ignored or blank for service types daily & weekly .
    What is simi-monthly - is that like semi-monthly and meaning partly monthly? Anyway leave that out for now

    Take WOM to mean Week of the Month
    I would start with calculating the date of precise period, check for a WOM value and if not blank move the date on to that WOM (forward)
    Then check if there is a dayofweek value, move on again to that.

    The mechanics of that could probably be in a UDF (function) called perhaps by a field rule.

    Comment


      #3
      Re: Complex calculation for determining the value of a field

      Semi-Monthly is 2 times a month(usually on set dates or on those but a certain day of the week) like 15the and 1st at each Monday after

      You forgot bi-weekly = every 2 weeks on a certain day of the week.

      Almost sounds like buy here & pay here in the car business.
      Dave Mason
      [email protected]
      Skype is dave.mason46

      Comment


        #4
        Re: Complex calculation for determining the value of a field

        Kieth,
        Field rules will never handle all of what you are trying to do. You will have to rely heavy on variables along with scripts, but mostly on some udf's to get this done.

        EDIT: Maybe I am over complicating it for you because we had to do this everytime a payment was made for the next one and a field was present for the next or we made a table entry for that customer where the may have as many as 200 payments to post against.

        I think the purpose for which you are creating this will help all here to help you. It has been a while since I crossed some of this stuff.
        Last edited by DaveM; 01-29-2013, 01:22 PM.
        Dave Mason
        [email protected]
        Skype is dave.mason46

        Comment


          #5
          Re: Complex calculation for determining the value of a field

          After sleeping on it over night and some more thinking this morning I have found a way to do this. I changed the field rules to make the next_svcdate a user entered field type. On the form I set variables for svcdate, svctype, week & dayofweek. I then modified the OnChange event for all 4 of those form fields to execute a script where I do all the complex calculations to determine the correct next_svcdate. When the script is finished I update the next_svcdate field on the form with the calculated value from the script.

          At this point this seems to be working. I just need to finish all the complex calculations and I should be good to go.

          Comment


            #6
            Re: Complex calculation for determining the value of a field

            Originally posted by DaveM View Post
            Semi-Monthly is 2 times a month(usually on set dates or on those but a certain day of the week) like 15the and 1st at each Monday after

            You forgot bi-weekly = every 2 weeks on a certain day of the week.

            Almost sounds like buy here & pay here in the car business.
            I looked it up, you are right. Bi-monthly can mean BOTH strangely enough but semi monthly is as you say twice a month.
            bi�month�ly /baɪˈmʌnθli/ adjective
            1 : occurring every two months
            ▪ The group holds bimonthly meetings in January, March, May, and so on.
            2 : occurring twice a month : semimonthly
            ▪ The group holds bimonthly meetings on the first and third Tuesday of each month.

            Comment


              #7
              Re: Complex calculation for determining the value of a field

              I had to use this to compute payments based on many different scenarios.

              Just a minute portion of one script:
              Code:
              select
              	case type = 1 'weekly
              		peryr = 52
              	case type = 3 'monthly
              		peryr = 12
              	case type = 2 'biweekly
              		peryr = 26
              	case type = 4 'simi-month
              		peryr = 24
              	case type = 5 'quarter
              		peryr = 4
              end select
              There is also semiannual and annual, which I never had to use
              Dave Mason
              [email protected]
              Skype is dave.mason46

              Comment


                #8
                Re: Complex calculation for determining the value of a field

                I just threw this together. Obviously you'll have to tweak it. But save it as a UDF and you can start playing with it.

                Code:
                FUNCTION NextServiceDate AS D (ServiceDate AS D, ServiceType AS C, ServiceWeek = 1, ServiceDay = -1 )
                	'error checking (look for invalid date, type, etc.)
                	if ServiceDate = {} then
                		'add error checking here
                	end if
                	
                	if ServiceType = "" then
                		'add error checking here
                	end if
                	
                	if .not. between(ServiceWeek, 1, 5) then
                		'add error checking here
                	end if
                	
                	if .not. between(ServiceDay, -1, 6) then
                		'add error checking here
                		'the -1 indicates that the same day of the week should be used
                	end if
                	
                	ServiceType = ut(ServiceType)
                	
                	select
                		case ServiceType = "DAILY"
                			NextServiceDate = ServiceDate + 1
                		
                		case ServiceType = "WEEKLY"
                			if ServiceDay = -1 then	'-1 indicates that we should use the same day of week
                				NextServiceDate = ServiceDate + 7
                			else					'otherwise use day of week provided (0=Sun, 1=Mon, etc)
                				NextServiceDate = ServiceDate - dow(ServiceDate) + 8 + ServiceDay
                			end if
                		
                		case ServiceType = "BI-WEEKLY"
                			if ServiceDay = -1 then	'-1 indicates that we should use the same day of week
                				NextServiceDate = ServiceDate + 14
                			else					'otherwise use day of week provided (0=Sun, 1=Mon, etc)
                				NextServiceDate = ServiceDate - dow(ServiceDate) + 15 + ServiceDay
                			end if
                		
                		case ServiceType = "MONTHLY"
                			if ServiceDay = -1 then
                				ServiceDay = dow(ServiceDate)
                			end if
                			
                			dim DaysofWeek as c = "Sun,Mon,Tue,Wed,Thu,Fri,Sat"
                			NextServiceDate = nth_dow(word(DaysofWeek,ServiceDay + 1,","),month(addmonths(ServiceDate,1)),year(addmonths(ServiceDate,1)),ServiceWeek)
                		
                	end select
                	
                END FUNCTION
                Stephen Pilon
                Associate Librarian
                Christendom College

                Comment

                Working...
                X