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

Saving Calculated fields to table from form

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

  • Saving Calculated fields to table from form

    Hiu

    I have a calculated field in a form that works out the commission.
    I need to set this value to a commission field in a table to use on reports for showing commissions owed to agents.

    I cant seem to find a way to do this.

    Please help.. im fairly new to alpha 9

    Thanks
    Ash

  • #2
    Re: Saving Calculated fields to table from form

    Hi Ash,

    Have you looked at Calculated field in Field Rules?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    Comment


    • #3
      Re: Saving Calculated fields to table from form

      Hi Keith
      Yes i have.. but the calcs are too complex for that facility i think!

      I have tried to save the calc into a variable but cant seem to find a way to select a calculated value.

      Regards
      Ash

      Comment


      • #4
        Re: Saving Calculated fields to table from form

        Hi Ash,

        If you can get a value into the field then you should be able to export it to Excel.

        You cannot export the value of a calculated field from a form or browse.
        Regards
        Keith Hubert
        Alpha Guild Member
        London.
        KHDB Management Systems
        Skype = keith.hubert


        For your day-to-day Needs, you Need an Alpha Database!

        Comment


        • #5
          Re: Saving Calculated fields to table from form

          Hi Keith

          Im not trying to export the value to excel.

          What i want to do is write back a calculated value from a form to a field in the table.

          ie,,
          calculated fields in a form

          comm1 = if(calc->F>calc->B,((calc->B*.12)+(0.5*calc->G)),0)
          comm2 = if(calc->F=calc->B,(calc->F*.12),0)
          comm3 = if(calc->F<calc->B,(calc->F*.1),0)
          comm4 = calc->comm1+calc->comm2+calc->comm3
          comm = if(tbl_orders->Ostage="cancelled",0,calc->comm4)

          i want to write comm into a table called tbl_orders, and field name Ocomm.

          Regards

          Ash

          Comment


          • #6
            Re: Saving Calculated fields to table from form

            Ash,

            1) tell us about the complete context in which this is occurring. Is the target table open? Is the record pointer in that table pointing to the desired record? What "mode" is the table in? Are you creating a new record, or updating an existing record ? Is this table external to the tables supporting the form?

            2) you will need to select an "event" to trigger the write. Are you thinking this would be a button push or something else?

            As you're pondering these questions you might check the help file topic <tbl>.change_begin() to see an easy example of how one might "write" a known value to a field in a table.

            Comment


            • #7
              Re: Saving Calculated fields to table from form

              If the user must push a button to save the record then you can have code to set a value to a field before saving. Assume you have a field comm1 in your table, then something like:

              Code:
              t = table.current(1) ' get a pointer to table
              t.comm1 = if(calc->F>calc->B,((calc->B*.12)+(0.5*calc->G)),0)
              parentform.commit 'saves record
              Hope this helps.

              Comment


              • #8
                Re: Saving Calculated fields to table from form

                Hi
                Thanks for the replies

                I am trying to do it as a on exit event.. the form is already using the table im trying to update, and the record is being updated and not a new one created.

                The form is in normal system default mode.

                all i need to do is to write the calculated field to the field in the record.

                Hope im explaining it right!!

                Regards
                Ash

                Comment


                • #9
                  Re: Saving Calculated fields to table from form

                  Did you look at my code?
                  This works whether entering a new record or changing an existing record.
                  After every edit you must save changes or they are lost!

                  Comment


                  • #10
                    Re: Saving Calculated fields to table from form

                    Hi Gary

                    yes i had a look at that.. but i have one field called Ocomm, which needs to be set to the calculated value comm.
                    However, comm is calculated from a number of calculations as shown above.

                    I was hoping that i can take the final value comm and write this to the field in the table.?

                    or do i put the whole calculation routine inside your code somehow..

                    Sorry i must sound a little thick!!

                    Regards
                    Ash

                    Comment


                    • #11
                      Re: Saving Calculated fields to table from form

                      Ash, I think the OnExit event for the form won't work. It fires after the form closes. The calculated display field vanishes when the form closes. Suggest you review the list of available "events" and choose another. If data entry is occurring perhaps the forms's CanSave event would be a better choice ?

                      See the help file topic "Object Events" for a list of form events and an explanation on when they each occur.

                      Comment


                      • #12
                        Re: Saving Calculated fields to table from form

                        Ash, there are two ways to write known values to the table.

                        1) you can "set" the text or value property of the object displaying the field in your form layout; or

                        2) you can use a pointer to the table supporting the form and reference the desired field using the pointer.

                        the syntax for these two sequences is different, as you might expect.

                        Is the target field being displayed in your form layout? If so, what's the object name that is displaying the target field?

                        Comment


                        • #13
                          Re: Saving Calculated fields to table from form

                          Ash,

                          One other thing you may can consider would be a UDF. If the complex calculation could be put within a UDF with the necessary parameters passed to it, that UDF could be accessed on the form and accessed by a new calculated field of the table. Rather than writing from the form to the table through events, this approach may simplify the calculation considerably.

                          The UDR approach would definitely be feasible if the only things which the calculation depended on were fields from the table. If, however, you needed, say, a rate specified on the form but not available from a table, the UDR approach may not be what you would need.

                          Steve

                          Comment


                          • #14
                            Re: Saving Calculated fields to table from form

                            Hi

                            Tom, The target field is not being displayed, but can be.. its called Ocomm. in a table called tbl_orders

                            Steve, not all the info i need for the calc are in table, UDF may not be possible

                            Comment


                            • #15
                              Re: Saving Calculated fields to table from form

                              Since no object in the form is available the first approach I mentioned is not available, either. So using code to talk directly to the table supporting the form is the approach to take:

                              it may be as simple as this:

                              In canSave event for the form:

                              Code:
                              tbl_ptr = table.get("tbl_orders")
                              tbl_ptr.Oocomm = Calc->comm

                              Comment

                              Working...
                              X