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

Tablesum() to get totals do not work

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

    Tablesum() to get totals do not work

    I still have problems with tablesum() a table to get its totals.
    I am attaching a sample DB. As you can see The sysntax in the field of the nameheader field called totused gives the value, during setup, in the actual form, does not show.
    The sysntax I am using in the form nameheader.dbf field totused is
    TABLESUM("nameitems.dbf","Id= " + QUOTE( Id_parent ) , "qtyused")

    The form is based in a set
    The id is in the nameheader.dbf
    The id_parent is the link in the nameitems.dbf
    qtyused is the field to use to total in the nameheader

    What is wrong with the syntax?

    #2
    Re: Tablesum() to get totals do not work

    Mike

    I have attached your zip file revised.

    You were trying to use a calcualated field based on a child table to load the total quantity for that parent id. You needed to use a posting field rule in the child table to update the parent key everytime a new entry is made in the child table.

    Using the calculated field, you would have to recacl the calculated fields after each entry into the child table. With the posting that is done for you.

    Look at the field rules in the parent table "nameheader". I have changed the "totused" field from calculated to user entered. Then look at the field rules in the child table "nameitems". I have added a posting rule to the field "qtyused". It adds the qtyused from the child table to the totused field in the nameheader table to the record that has the same id and the parentid in the child table.

    Now when you update a record in the child browse, it immediately updates the totused field in the master (parent) table and shows that new totused in the field on the form.

    I have also checked the rule to undo on delete, so that if you delete a record from the child table, the master table totused field will also be updated to show the total after the delete.

    Tom

    Comment


      #3
      Re: Tablesum() to get totals do not work

      Originally posted by MikeData View Post
      I still have problems with tablesum() a table to get its totals.
      I am attaching a sample DB. As you can see The sysntax in the field of the nameheader field called totused gives the value, during setup, in the actual form, does not show.
      The sysntax I am using in the form nameheader.dbf field totused is
      TABLESUM("nameitems.dbf","Id= " + QUOTE( Id_parent ) , "qtyused")

      The form is based in a set
      The id is in the nameheader.dbf
      The id_parent is the link in the nameitems.dbf
      qtyused is the field to use to total in the nameheader

      What is wrong with the syntax?
      Or....another approach...

      Comment


        #4
        Re: Tablesum() to get totals do not work

        As you can see The sysntax in the field of the nameheader field called totused gives the value, during setup, in the actual form, does not show.
        When calculated fields are calculated.
        There can be only one.

        Comment


          #5
          Re: Tablesum() to get totals do not work

          Tom Thanks for the revised sample. I did apply the process to another DB and it does update the fiels, but only after is refresh or saved.
          Stan has given me an indication why the fields are not updated.

          Thanks Stan.
          This information has created more questions than answers. Here is a quote

          When Calculated Fields are Calculated
          Merely adding a field to a table and giving it a field rule calculation expression does not fill the field with values. A field rule does not calculate until one of three events occurs.
          � A record is added to the table
          � One of the fields in the calculation is changed or edited in a record
          � Run the Re-Evaluate rules function.

          Here is a quote from the manual:
          <TBL>.RECALC_CALCFIELDS()
          Syntax
          <TBL>.RECALC_CALCFIELDS()
          Description
          The <TBL>.RECALC_CALCFIELDS() method recalculates the calculated field in a table. The calculated fields in a table are defined in Field Rules. Normally, as you enter and edit records in a table, the calculated fields are automatically recalculated. However, if you modify an Alpha Five table outside Alpha Five (e.g. by using a program that can read Alpha Five�s .dbf files), or by running some Alpha Five Operation (such as a Posting Operation), the calculated fields are not updated.


          Above statements correspond with my case in my other DB, yet it does not address the issue that in the sample Tom revised, the data is update immediately. On either of the DBs, above function has not been called.

          There must be a setting somewhere either, turn on or turn off the updating, to account for the difference.

          Comment


            #6
            Re: Tablesum() to get totals do not work

            Mike,

            In your original sample database. Right click on the table in the control panel, Utilities, Recalc Calc Fields. Open your form and the totals display.

            Start a new record and enter some products and quantities. Move to the prior record and come back (saving the current record). Change the name in the parent record, the calc fields will display.

            Not sure why the calculation does not trigger on new record entry.
            There can be only one.

            Comment


              #7
              Re: Tablesum() to get totals do not work

              Stan, Thanks.
              That is the problem. If you try the sample Tom returned, you will see that the results are all correct.
              Make a change and the data is updated in the total of the header form.
              If I apply that process to other DBs, They do not update the same way, They save, but do not display immediately

              Comment


                #8
                Re: Tablesum() to get totals do not work

                The real question in my mind is why you want to store this information in the header table when it is easily derived at any time with a calculated field on a form or report. Done that way you don't have to worry about a field rule posting or a field rule calculation not being up to date.
                There can be only one.

                Comment


                  #9
                  Re: Tablesum() to get totals do not work

                  In the past applications I have not stored the values of the subtable. I have used calculated variables. I believed it was you who have help me in the past to do do it.
                  Yes you can use calculations, but in this case the values are going to be used over and over many times and I was trying to avoid the calculations so many times.
                  I am still confused as why in one application we can accomplish it and others no.

                  Stan, Thanks for the help.

                  Comment


                    #10
                    Re: Tablesum() to get totals do not work

                    Mike, perhaps your confusion can be explained if you show us how you implemented the solution in the other db's you mention... ?

                    Comment


                      #11
                      Re: Tablesum() to get totals do not work

                      Tom I did the same syntax as to the revised sample.
                      The difference was that I did not applied the refresh option.

                      I was getting ready to prepare the sample for another question and found the option of a screen refresh to the ONSAVE event of the nameitems browse.
                      I did apply that change to my other DB and it is getting close to my objective.
                      Thanks.

                      Comment


                        #12
                        Re: Tablesum() to get totals do not work

                        Mike

                        I have been away and just read the rest of the responses in the thread.

                        I had forgotten to tell you to look at the browse OnSave event where I placed the refresh display action scripting.

                        As you have found, you need to refresh the display of the browse which saves the record and resynchs the tables as well as updating the parentform to reflect the new total in the "totsused" field.

                        Tom Baker

                        Comment


                          #13
                          Re: Tablesum() to get totals do not work

                          Again thanks for all the help.
                          It is great.

                          Comment


                            #14
                            Re: Tablesum() to get totals do not work

                            I am trying to manipulate data in a query set. I start with a database called proposals and I do a query by date range and salesman’s name. I then count the records in the set. Next, I want to total the dollar total of the proposals for that salesperson during the period queried. I am having difficulty totaling the field called Amount in the query set. I do not understanding the syntax of TABLESUM. I must be missing some thing. Is there an alternate method of summing the field? Amount is not an indexed field, but it is a numeric field. Your help will be appreciated.

                            Comment


                              #15
                              Re: Tablesum() to get totals do not work

                              Experiment with AlphaSports until you have a feel for tablesum(). Use the interactive window and

                              Code:
                              ? tablesum("invoice_items",".T.","extension")
                              = 13988.04
                              ? tablesum("invoice_items","invoice_number = '000006'","extension")
                              = 184.84
                              
                              inv_num = "000006"
                              ? tablesum("invoice_items","invoice_number = '"+inv_num+"'","extension") 
                              = 184.84
                              There can be only one.

                              Comment

                              Working...
                              X