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

Forcing form calculated fields to refresh

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

    Forcing form calculated fields to refresh

    You have nested calculated fields or in other words, calculated fields whose calculations reference other calculated fields. What happens if you replace those references with the actual calculation?

    valb = (4*7)/2

    instead of
    vala = 4*7
    valb = calc->vala/2

    to illustrate.
    There can be only one.

    #2
    Forcing form calculated fields to refresh

    I have a sales analysis form which measures the no of orders and revenue on a customer by customer basis. The user calls up a customer on the form and sees immediately the all invoices and line items ordered since time began, using two embeded browses, and with totals prominently at the top of the form.

    Looks exactly like this: tash2.jpg

    I added a "what have you bought from me lately" feature where I have a button called "Since_Date" used to specify any date and the form will recalculate new values of invoice counts and dollars. Problem is I can't find the magic wand to force the recalculation.

    I've tried different types of refreshes, commits, resynchs and all of these are being ignore or throwing errors. In Alpha Five Version One the calculations refreshed when I added the following routine to INIT and PUSH on the button that enters the Since_Date.
    change_begin(db_current())
    customer->c_sw = .NOT.customer->c_sw
    change_end(db_current(),.T.)
    card_resynch()
    This seemed so simple at the time.

    Does anyone who's been through this have an idea of something that's likely to work for me without throwing errors about the field needing to be in change mode or can't be in change mode. Seems my form doesn't respond well to beeing tested for its mode.

    I would love to have a solution to this nightmare I've created.

    Thanks much .. Sam

    Comment


      #3
      Re: Forcing form calculated fields to refresh

      Sam, as a rule calc display values are updated automatically when field values used in the expression change. I suspect this is happening for you when you "fetch" a new record by navigating to it.

      Others may have better ideas, but first thought here is that you could do the desired calculation in the button's onpush event script, and then write (assign) the computed values to text boxes on the form. Those text boxes would be bound to form level variables.

      Comment


        #4
        Re: Forcing form calculated fields to refresh

        To add to Tom's suggestion, if you have a form-calculated field, and you put it on the form, and name it possibly "my_form_calc," anywhere you like, as in onfetch, onsave, button push, etc., you would say my_form_calc.refresh() which will cause it to 'recalc' the value and update the screen
        Cole Custom Programming - Terrell, Texas
        972 524 8714
        [email protected]

        ____________________
        "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

        Comment


          #5
          Re: Forcing form calculated fields to refresh

          Thank you to both Tom and Martin for your suggestions. Tom, I'm goosy about adding the calcs to xbasic and then moving the values to the form fields. If that were my only choice, however, I would welcome it. I think I prefer Martin's suggestion if I understand it properly.

          Martin, if you look again at the screenshot of my earlier posting in this thread, the two fields that require recalculating are the ones on the second line of the "Purchase Overview" box at the top. They contain values of 100 and 2511.80 in the graphic.

          Are you saying to give them object names of say since_date_count and since_date_value and then in the PUSH event where the since-date is entered I would then simply write two lines saying since_date_count.refresh() and since_date_value.refresh()? No other xbasic statements required?

          Martin I'm still a bit dense with A5V11 so let me state what may be obvious to you. If this routine works for me and forces those two recalculations, then later when I exit the form and come back to it it will be business as usual where the form will do all its normal calculations, unless the user again enters a new or different since-date field at the button?

          I'll give this a try now while I'm awaiting a reply and let you know the result.

          Thanks very much Tom and Martin. --- Sam

          Comment


            #6
            Re: Forcing form calculated fields to refresh

            Martin, I added the 2 refresh statements and the screen didn't update.

            Comment


              #7
              Re: Forcing form calculated fields to refresh

              Originally posted by sgerber View Post
              I added a "what have you bought from me lately" feature where I have a button called "Since_Date" used to specify any date and the form will recalculate new values of invoice counts and dollars.
              What is the script on that button?

              Comment


                #8
                Re: Forcing form calculated fields to refresh

                Originally posted by G Gabriel View Post
                What is the script on that button?
                I appreciate your interest. If you look at the quote in my initial post in this thread you'll see the small routine that worked for me in Alpha 5 Version 1. When you look at the attached script you'll see some attempts to use a similar idea which is writing a byte to the primary record. That caused the form to recalculate its calc fields and refresh the display. This routine was in two places: INIT of the form and ONPUSH of the button.

                The problem I have with V11 is that I can't successfully test the mode of the form (View vs Change). Now I've started looking at testing the mode of the table instead. Every time I think I've got it close to working it gives an error like you're starting a change and you're already in change mode. And then unpredictably it will throw the opposite error that I'm trying to write and the form is NOT in change mode.

                I put a routine in my form suggested by someone in these forums which monitors the status of the form by using parentform.mode_get(). The status of my form ALWAYS shows as "VIEW" and yet I'll get an XBASIC error telling me the file is in change mode.

                When you wrote to me I was about to investigate the difference between the form being in change mode versus the table being in change mode. It appears that the FORM can be always in VIEW mode and yet the table somehow can be in CHANGE mode. Yikes.

                Here's the Script "G Gabriel" and best of luck helping me. Thank you ... Sam
                Attached Files

                Comment


                  #9
                  Re: Forcing form calculated fields to refresh

                  Sam
                  I see no query/filter action taking place in that code.
                  The date you're getting is stored in two variables.
                  Are these variables used in a set or form rule elsewhere?
                  There is no purpose as far as I can see for all the code changing C_SW

                  Comment


                    #10
                    Re: Forcing form calculated fields to refresh

                    Sam,
                    That is not a "calculated field"
                    a calcualted fied is based on an expression, and using the form's calcualated fields

                    you could make a function with the code in it, and use the function at the various events
                    Cole Custom Programming - Terrell, Texas
                    972 524 8714
                    [email protected]

                    ____________________
                    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                    Comment


                      #11
                      Re: Forcing form calculated fields to refresh

                      Originally posted by Ray in Capetown View Post
                      Sam
                      I see no query/filter action taking place in that code.
                      The date you're getting is stored in two variables.
                      Are these variables used in a set or form rule elsewhere?
                      There is no purpose as far as I can see for all the code changing C_SW
                      Hi Ray. Not sure what you mean by the date being stored in TWO variables. I have a declared form variable called "i_since_date". It receives the user input from the GUI you saw and is bound to a form field. That field updates on the screen after being entered and is used in the calculations. I'll attach my calculations here for clarity:A5Calcs.jpg
                      As for my changing a field in the customer record I don't know enough to comment on that. All I know for certainty is that the routine you looked at that was used in A5V1 was suggested on the forum back in around 1996 and it has worked perfectly for 16 years.

                      Ray, I'm puzzled by your posting. Why would you expect there to be a query/filter action? That code simply addresses the current record of the primary database in the set. Why a query or filter. Also, Ray it seems you only focused on my inputting the variable. My problem is that I can't get the form to use that variable and launch a recalc immediately. What happens now is that the form will update if I advance to the next form and then come back, but right now that's giving me a different problem.

                      Does this help you at all?

                      Thanks .. Sam

                      Comment


                        #12
                        Re: Forcing form calculated fields to refresh

                        Originally posted by martinwcole View Post
                        Sam,
                        That is not a "calculated field"
                        a calcualted fied is based on an expression, and using the form's calcualated fields

                        you could make a function with the code in it, and use the function at the various events
                        Hi Martin. I know it's not a calculated field. Apparently I misread your suggestion. I assigned object names to the two calculated fields that depend on that variable and I then took your advice and refreshed those two form objects thinking that it would force them to recalculate.

                        Isn't that what you were explaining?

                        Comment


                          #13
                          Re: Forcing form calculated fields to refresh

                          Yes and No - it is correct for a "calculated field"
                          but since these are not calculated fields, then you have to run the script and then refresh the fields
                          Cole Custom Programming - Terrell, Texas
                          972 524 8714
                          [email protected]

                          ____________________
                          "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                          Comment


                            #14
                            Re: Forcing form calculated fields to refresh

                            Hi Sam - aren't you making a query on certain records ? (beyond specified date)
                            I was just expecting to see some reference to that on the code for the button that selects that date. Simply because thats where I would.
                            But there are many other ways you could be applying that query.

                            I have tried your explanation out. If I apply a query on child records only, my form calculations are refreshing.
                            That is using both some code;
                            Code:
                            sDate=date()-100 ' a date
                            p=table.current(2)
                            query.order = "recno()"
                            query.options = ""
                            query.filter = "tentran->date < " + s_quote(sDate)
                            ' didnt need for this on child only query.filter = "flattenquery(" + filter + ")"
                            qry = p.query_create()
                            as well as the form's Query Genie

                            THAT is why there have been requests for a sample of your database. Help us to help you.
                            You should just scale down sample dbfs, dummy up, and switch those tables when sending - otherwise you will continue to struggle with explanations only as you go forward.
                            This could have been cleared up after the first couple of posts.

                            PS for the others reading this - I struggled long, and failed, to get child query to work using Queryrun() - if anyone has or knows how, please show.
                            Last edited by Ray in Capetown; 09-06-2012, 01:26 PM.

                            Comment


                              #15
                              Re: Forcing form calculated fields to refresh

                              Originally posted by martinwcole View Post
                              Yes and No - it is correct for a "calculated field"
                              but since these are not calculated fields, then you have to run the script and then refresh the fields
                              Martin, excuse me for being dense. The two fields I mentioned ARE calculated fields. What are you saying when you said "then refresh the fields". I tried to use your technique to refresh those fields. You seem to be asking me to do something that I've already done.

                              Can you explain once more what exactly you think will refresh those two calculated fields?

                              Comment

                              Working...
                              X