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

Child Browse-->Save Parent

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

    Child Browse-->Save Parent

    The child browse consists of line items (hours * rate = fee). The user changes the value of a line item. I want the total function value (of the child items) to be written to the Total field of the parent table. There is also a single expense item in the parent table which must be included as part of the parent total. What is the best way to do this?

    The issue is the way in that the child save is not captured in the form's OnSave event. Where can I put the code so that it always updates the parent total field regardless of whether a user changes a child line item or a parent expense?

    Peter
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    RE: Child Browse-->Save Parent

    Peter,

    I had a similar issue and I placed parentform.refresh() on both the OnEnter and OnActivate events of the parent form. Might have been an over kill but it works.

    Makes me happy.

    kenn
    TYVM :) kenn

    Knowing what you can achieve will not become reality until you imagine and explore.

    Comment


      #3
      RE: Child Browse-->Save Parent

      Hi Ken,

      It's not a refresh issue, rather where to put code to save either parent or child changes or both.

      Peter
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        RE: Child Browse-->Save Parent

        Peter, if I understand correctly, you have a total from each record in a one-many child, and you want the parent field to reflect the sum of the TOTAL fields from all child records. Also, you want to add to that a value from the parent.

        If the parent value is entered prior to entering the child records, you could have the TOTAL field from the child post to the parent field (adding). So, if the parent value started as 20, and each of 2 child totals was 7, the parent field would show 34.

        If you're going to change the parent total after entering the child records, this will get a little trickier. In this case, you might want to have a second field in the parent that is a calculated sum of the parent field plus the posted field from the child.

        I've used posting from child to parent a lot, and it seems quite reliable.

        Comment


          #5
          RE: Child Browse-->Save Parent

          If you're going to change the parent total after entering the child records

          Yep.

          Your posting method would work, but I want to find another way because the child table has different parents, so posting can't be used.

          Thanks,
          Peter
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            RE: Child Browse-->Save Parent

            OK, thinking out loud...how about a calc field in the parent that uses DBSUM to retrieve the value from the child. each time you add or change a child record, you would have to re-evaluate the parent, but that shouldn't be too hard.

            Maybe??

            Comment


              #7
              RE: Child Browse-->Save Parent

              Ok, more to the point. How di I force the parent to reevaluate when the child value changes? Keep in mind this is a child browse, so users typically arrow down to the next record (which saves the child value) or they may use the save button the parent form.

              Peter
              Peter
              AlphaBase Solutions, LLC

              [email protected]
              https://www.alphabasesolutions.com


              Comment


                #8
                RE: Child Browse-->Save Parent

                Perhaps the row change events (CanRowChange-test for the mode of the browse) and OnRowChange-set initial value in the field to test against the value on departing) might work. But a safer method might be to not use the browse at all for the data entry. Capture the data in form variables and update the browse and parent records as required.

                Comment


                  #9
                  RE: Child Browse-->Save Parent

                  Peter:

                  If I might be so bold, here's how I would do it...

                  I'm guessing your doing your data entry for the child records in a browse, so, if this is correct:

                  Define a global variable in the autoexec called, say, "update_required" as logical.

                  In the field rules for the table, place a statement setting the variable to .T. on the onsaverecord event. Do the same for the OnChangeRecord event.

                  On the OnArrive for the embedded browse, set the variable to .F.

                  On the OnDepart for the browse, using XBasic, If the variable is .T., determine the total for the child records, then write the total to the parent field. (If the variable is .F., end) Then, lastly, set the variable back to .F.

                  Place the same code on the OnRowChange event.

                  A screen refresh() would be a good idea, now, to ensure the new total is reflected.

                  You might want to add a button to close the form. Although the OnDepart will fire if the 'X' is used to close the form, I would set it up so that the form can only be closed with the button being pushed.

                  This will only work if you just use the one form for data entry, so...

                  If you are interested, and need more details, let me know...

                  Craig

                  Comment


                    #10
                    RE: Child Browse-->Save Parent

                    there are lots of ways to do what you want, but one of the
                    easiest was described by barry rochford in
                    http://www.learn alpha.com/InvoiceTotal/InvoiceTotal.htm

                    Comment


                      #11
                      RE: Child Browse-->Save Parent

                      Thank you Peter. Yes, I remember Barry's article quite well. I do use that method on certain sets. From a button script it works flawlessly. My problem is updating the total from the child browse - the total needs to be updated when the child value changes or the parent expense value changes.

                      Peter
                      Peter
                      AlphaBase Solutions, LLC

                      [email protected]
                      https://www.alphabasesolutions.com


                      Comment


                        #12
                        RE: Child Browse-->Save Parent

                        Thanks Craig. Your method is a little complex, but in any case it depends on the browse OnDepart event to update the total. I need to have the update occur if a value is changed on one child record - as the user may typically change one record after the other.

                        Peter
                        Peter
                        AlphaBase Solutions, LLC

                        [email protected]
                        https://www.alphabasesolutions.com


                        Comment


                          #13
                          RE: Child Browse-->Save Parent

                          Capture the data in form variables and update the browse and parent records as required.

                          Thanks Balto, CPA.

                          I think I'm ready to throw in the towel at this point. I will just display the callc field total (which updates just the way I want in all cases) and save the Calc->Total value in the forms CanExit event. That should work. If not, to quote Arnie "I'll be back".

                          Peter
                          Peter
                          AlphaBase Solutions, LLC

                          [email protected]
                          https://www.alphabasesolutions.com


                          Comment


                            #14
                            RE: Child Browse-->Save Parent

                            I think I'm ready to throw in the towel at this point. I will just display the callc field total (which updates just the way I want in all cases) and save the Calc->Total value in the forms CanExit event. That should work. If not, to quote Arnie "I'll be back".

                            Peter
                            -----------------------------
                            It should work fine for you and I sure don't want to complicate things. I'll just mention that I tend to follow Murphy's Law on these things and if you were to deploy this on a mult-user system, it's possible to get some unexpected results.

                            e.g.
                            I enter the record and change the header to $20 and move to the browse thereby releasing the lock. While I'm in the browse, another user enters the header and changes the value to $10. I exit the record and cause a write operation using the $20 value. The other user exits the record causing a write operation using the $10 value. It's probably an unlikely event and I'm over complicating it. I just finished a form which handles this event in the Beta and wound up with quite a bit of code on the form since I didn't want to use referential integrity. But RI might prevent this...I didn't test it.

                            Comment


                              #15
                              RE: Child Browse-->Save Parent

                              Good point (yes it is a network application). Since this form will be used as a dialog, I will code a lock on the parent record, so a second user can't access the record while in edit mode.

                              Peter
                              Peter
                              AlphaBase Solutions, LLC

                              [email protected]
                              https://www.alphabasesolutions.com


                              Comment

                              Working...
                              X