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

Field Level Calculations

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

    Field Level Calculations

    Client has 2 numeric fields;
    Meters, Yards.
    They can enter the fields in either order, Yards OR Meters.
    Depending on which has been entered, I need to calculate the other.

    The calculation is simple, however the order of entry is more problematic.
    I cannot simply Skip a field with data present as a mistake may have been made.

    Logically;
    Enter Meters, Insert calculation into Yards - easy
    Edit Yards, recalculate Meters - data already present
    Enter Yards, Insert calculation into Meters

    All ideas welcome and off to review Script conditional firing in the meantime.
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    We are the
    Department of Sunshine and Rainbows!

    Hope restored, faith renewed, spirits lifted!

    #2
    Re: Field Level Calculations

    First thought would be to code the onchange event of each to calculate the other.
    There can be only one.

    Comment


      #3
      Re: Field Level Calculations

      Thanks Stan. I was about to post that I had a solution similar to the above.
      Appreciate your time.
      See our Hybrid Option here;
      https://hybridapps.example-software.com/


      We are the
      Department of Sunshine and Rainbows!

      Hope restored, faith renewed, spirits lifted!

      Comment


        #4
        Re: Field Level Calculations

        So I won't get in a loop with OnChange?
        See our Hybrid Option here;
        https://hybridapps.example-software.com/


        We are the
        Department of Sunshine and Rainbows!

        Hope restored, faith renewed, spirits lifted!

        Comment


          #5
          Re: Field Level Calculations

          For type-in fields, the onchange event fires when the control looses focus.
          Since the value is being changed behind the scenes with code and the object is never given focus, no loop.

          My initial thought was to use the ondepart event for the fields but that would require coding to skip over the second of them, in tab order, in the ondepart of the first and force the user to click or back-tab into the second to change it.
          Last edited by Stan Mathews; 09-22-2017, 09:33 AM.
          There can be only one.

          Comment


            #6
            Re: Field Level Calculations

            Spot on Stan. I have just tested your suggestion and no loop.
            The way I approached it initially was to set a procedure to clear the fields and whichever was entered recalculated the other.
            The OnChange works if there is an erroneous data entry so doesn't require fields to be cleared. IE more simple.
            See our Hybrid Option here;
            https://hybridapps.example-software.com/


            We are the
            Department of Sunshine and Rainbows!

            Hope restored, faith renewed, spirits lifted!

            Comment


              #7
              Re: Field Level Calculations

              Simple is my middle name.
              There can be only one.

              Comment


                #8
                Re: Field Level Calculations

                Quickbooks does this on an invoice to calculate the amount when you change the quantity and / or price ; and if you change the amount, it recalculates the price - always wondered how to do that.

                Do you think it could be done at the field rule level so it would work the same in a browse?
                Last edited by MoGrace; 09-22-2017, 11:19 AM.
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment


                  #9
                  Re: Field Level Calculations

                  Seems to work ok in the field rules

                  onwrotefield event for price field -

                  tbl = table.current()
                  tbl.amount = tbl.qty*tbl.price

                  onwrotefield event for amount field -

                  tbl = table.current()
                  tbl.price = tbl.amount/tbl.qty

                  Not sure what sort of logic you might want to handle uneven divisors. Suppose quantity is 3 and price is 11.50, yields amount 34.50. Change amount to 34.00, yields price 11.3333....., but extension of 3*11.33 (as stored in a field with two decimal places) is 33.99.

                  Probably something like

                  tbl = table.current()
                  tbl.price = tbl.amount/tbl.qty
                  if tbl.amount/tbl.qty <> round(tbl.amount/tbl.qty,2)
                  tbl.amount = round(tbl.amount/tbl.qty,2)*tbl.qty
                  end if

                  and you would, of course, need to code the onwrotefield event of the quantity field to recalculate the amount based on the price.
                  Last edited by Stan Mathews; 09-22-2017, 12:13 PM.
                  There can be only one.

                  Comment


                    #10
                    Re: Field Level Calculations

                    The table I am thinking of is one I use to import summary invoices from Alpha into QB. QB allows 5 decimal places for price, but the import can use either the price or the amount field. And since Alpha is used to print the detailed invoices, I can import fixed values for quantity and amount and let QB calc the price. So in the temp table I create in Alpha, if the summary is off a penny or 10, this field rule will allow me to correct the total amount I need to match before importing. Adding an OnKey event to use the + and - keys to change the amount by pennies, makes this a really quick fix in Alpha using a browse view.

                    Well quick for me since I usually summarize less than 20 invoices at a time.

                    hmmm, now that I think about that a bit - the OnKey event may be all I really need if I can skip the price field in the import...
                    Last edited by MoGrace; 09-22-2017, 03:22 PM.
                    Robin

                    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                    Comment


                      #11
                      Re: Field Level Calculations

                      This is just another example of why I do data entry using dialogs. So much much more control. All calculations and checks done then enter data to the tables.
                      Mike W
                      __________________________
                      "I rebel in at least small things to express to the world that I have not completely surrendered"

                      Comment


                        #12
                        Re: Field Level Calculations

                        I am using Transaction Pro Importer to bring the Alpha data into QB and I discovered a command line switch I can use to select Amount instead of Price - which solves the entire problem and allows QB to calculate the price instead of the amount.
                        Robin

                        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                        Comment

                        Working...
                        X