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 question

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

    Tablesum question

    Trying to define a Parent field rule to sum the value of a field in its child records.

    tablesum("HSDETAIL",".T.","NO_KEYS" yields sum of all "NO_KEYS" in all child records.

    Assume I have to somehow substitute ".T." with the value of the current parent record. But how ?

    Suggestions appreciated.

    John

    #2
    RE: Tablesum question

    Yes, you need to substitute an expression that evaluates to true for the records you want totaled. If the linking field in the parent and child is called link it would be something like:

    tablesum("HSDETAIL","link=parent->link","NO_KEYS")

    Another way to do this is to index the child by the linking field and use the dbsum expression.

    Comment


      #3
      RE: Tablesum question

      Ohlen

      Thanks for your response, tried the following but got
      "filter expression not logical"

      tablesum("HSDETAIL","S_D_K=HSMASTER->S_D_K","NOKEYS")

      S_D_K is the linking field. If I remove "HSMASTER->" I get the sum of all NOKEYS for all child records.

      Have I misinterpreted your example ?
      Thanks, John

      Comment


        #4
        RE: Tablesum question

        I think you interpreted it exactly. Try:

        tablesum("HSDETAIL","S_D_K=+HSMASTER->S_D_K+","NOKEYS"

        to try to force the expression to evaluate the value of the field in the parent table.

        Comment


          #5
          RE: Tablesum question

          John, are you sure you want to do this in a table level field rule for records in the parent table?

          Are you expecting the value to be updated for you automatically as new child records are added? If so, I think you'll find that it won't work that way, since the parent table won't have any way of knowing about data entry into the child table. Be sure and let me know if you get it going. I'll be surprised, but it won't be for the first time!

          There are two other ideas which you might want to consider:

          1) Define a table level field rule for the child table. In that rule, 'post' transaction data from each new child record to a field in the parent table. By 'adding' the transaction data to the parent table field you can keep a running total pretty easily.

          - or-

          2) Use a form level calculated display field to track the running total of all related child records. At key points, as for example, whenever a new child table record is saved, arrange for a short script in the form to update the desired field in the parent table.

          -- tom





          Comment


            #6
            RE: Tablesum question

            Ohlen,

            Tried TABLESUM("HSDETAIL", "S_D_K=+ HSMASTER->S_D_K+","Nokeys")

            Error "Expected Value"

            Tried TABLESUM("HSDETAIL", "S_D_K=+ HSMASTER->S_D_K","Nokeys") (Removed 2 nd + "

            Error "Argument is incorrect data type".

            Can you think of anything else ?

            Thanks, John

            Comment


              #7
              RE: Tablesum question

              Tom

              Thanks for the response.

              Like the sound of option 1. However I am unable to get TABLESUM or DBSUM to work for an individual group of child records. Will work fine to total all records. The problem appears to be defining the "FILTER" in Tablesum to yield a true result. Any suggestions ?

              PS. Seperate issue, when doing an append I sometimes get error "read past end of file" on one machine, yet on another works tickity boo. (Same data both mahines" ??

              Thanks, John

              Comment


                #8
                RE: Tablesum question

                Option 1 would not use dbsum() or tablesum(). It would be a simple post from new child records to the parent table.

                -- tom

                Comment


                  #9
                  RE: Tablesum question

                  Thanks
                  Will try
                  John

                  Comment


                    #10
                    RE: Tablesum question

                    John,

                    Here's how I got this to work in my app. I defined a calculated field at the set level (not a field rule calculated field) and used this expression.


                    dbsum("charges.dbf","charges_by_type",tranno,"fee")

                    where charges.dbf is the child table, charges_by_type is the index, tranno is the linking field, and fee is the field to be summed. I didn't try this on a field rule calculated field. As I recall, I tried the tablesum expression in a calculated field and in a calculated field rule field and, despite my previous post, could not get a filter defined either.

                    Comment


                      #11
                      RE: Tablesum question

                      Tom
                      Works like a charm when adding detail records. Thank you

                      However I'm still left with the problem of updating the master records with the count of all the existing child records. I assume I will have to use Tablesum or Dbsum but I can't seem to get either to work.

                      Any words of wisdom

                      Thanks, John

                      Comment


                        #12
                        RE: Tablesum question

                        Ohlen
                        Tried your suggestion but unfortunately the result is 0. May haps I've missed something. Will keep trying.
                        Thanks for your efforts.
                        John

                        Comment


                          #13
                          RE: Tablesum question

                          Why not define an update operation and use an expression that totals the child table values? Run it once. Then, from that point on, using the posting field rule in the child table to update the parent table record as changes occur in the child table.

                          My point, in the earlier message, was that I had misgivings about trying to use tablesum() in a parent table field rule, as you were attempting.

                          By the way, when working on new operations it is prudent to 'develop' the new operation while working on a throw away copy of your real data. Don't run an operation against your real data until you are sure it will work as you expect. Some of us are missing a few toes, because we shot ourselves in the foot, doing new operations on our actual data. This usually happens when we think we know what the heck we're doing, and have decided that testing on dummy data would be a waste of time. Not!

                          -- tom

                          Comment


                            #14
                            RE: Tablesum question

                            Tom,

                            Did it & it worked. Thanks so much. One less problem to worry about. Based on similar past experiences, I always backup my application prior to shooting myself.

                            John

                            Comment


                              #15
                              RE: Tablesum question

                              Congratulations!

                              -- tom

                              Comment

                              Working...
                              X