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

Calculated fields on a form

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

    Calculated fields on a form

    Attached to this file are 3 tables and 1 set. Two of the tables (equip and component_history) form a set with a one-to-many link on field "LOCO". The third table is a lookup for component. The form has 7 columns. The first column is where the user selects a component from the lookup table. The second column is a calculated field for a total of the number of times that component has been changed on the locomotive (not blank - applied date and removed date). The third column calculates the average life of the removed components. The fourth column allows the user to enter what he/she forecasts the life of the component to be. The fifth column is a count of the number of components currently applied to the locomotive (loco = loco, isnotblank applied date and isblank removed date) The sixth column calculates the number of components needing to be changed by the variable "Change by Date" based upon the average life of the removed components. This column is hidden if the average life=0. The last column calculates the number of components needing to be changed by the variable "Change by Date" based upon the forecast life of the components.

    I have put an browse on the form to check the accuracy of the calculations, it will not be part of the final form. The problem has to do with the 2 count columns. They do not consistantly show the proper counts. Often they seem to add an additional component for each row. I have also found that if I remove the calculations for the last 2 columns, the second and fith columns will count correctly. I think the problem is the way ALPHA handles the calculations. I hope I am wrong and that I have made an error as I have placed a lot of faith in Alpha and use many many calculations throughout my product. I am using A5 V4.5 build 266.

    A secondary question, the "change by date" field is a variable because I want it to be the same on all the forms, I will be using it on reports, and I want the user to have the ability to play "What If?" with the date. How to I get the form to recalculate when this date is changed? I have tried refresh and resynch for the on change event for the field and they do nothing. The equip and component_history tables have many more fields in the actual program. They have all been removed and the tables now contain only the fields pertinent to the form.

    This message board has come thru for me many times. I hope you can find it within yourselves to do it again.

    Thank you

    Dick Blanchard

    #2
    RE: Calculated fields on a form

    Dick:

    Answering only one thing because I'm not as advanced as others on this board...

    The calculated fields refreshing 'on-the-fly' -- Here's what I've found. If the problem calculated field uses the result of another calculated field in its formula, The darned field won't update no matter what you do short of closing the form and reopening it.

    If, however, you use that [other] calculated field's formula [instead of its name] in the current one everything snaps 'on-the-fly'.

    I discovered this in a field rule calculation and then reconfirmed it on a from as well.

    Ken the Newbie

    Comment


      #3
      RE: Calculated fields on a form

      Richard,

      I've taken a quick look at your files.

      If it were me, I'd investigate using a form based on the Equip table alone.

      (Using tablecount() tableavg() and tablesum() functions to supply necessary values from Component history table. I find these much more straightforward than the grouping and subgrouping expressions required of other functions, like count() or total(). Furthermore, since your form is based on the set Alpha Five must keep track of where the parent and child table record pointers are at all times, yet you force Alpha Five to scan and re-scan the linked child table records in your calc expressions, applying various filters to include or exclude different child table records from your calculations. This makes me nervous as a cat in a room full of rocking chairs. Maybe it can be made to work, but all that activity seems fraught with peril to me, occurring as it does, in the context of a set based on the same child tables.

      Questions that come to mind when I look at your calculation expressions:

      1) how does Alpha Five evaluate the table name 'Component History'? The blank space is ambiguous and has caused me trouble in other contexts. I've sworn off them entirely and refuse to use a field or table name that contains one.

      2) are your expressions mismatching because you are inadvertantly comparing strings of differing lengths. i.e. should you be careful to trim trailing blanks from field values?

      Hope these comments help.

      -- tom

      Comment


        #4
        RE: Calculated fields on a form

        Dick,
        Just as a general point I think Tom Cone's suggestion with regard to alternate ways of handling complexity may be well advised. I suppose in theory the product should be able to do whatever you code into it. However, more practically, it might be better to think creatively and somehow simplify. I learned that lesson the hard way after years of going down the wrong path.

        >>How to I get the form to recalculate when this date is changed?
        Peter
        AlphaBase Solutions, LLC

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


        Comment


          #5
          RE: Calculated fields on a form

          Tom
          Thank you for your reply, but unfortunately I could not make the TABLECOUNT() function work. It does great with a straight foreward expression like "field='field_value'" but cannot handle expressions with variables or fields from other tables. The problem has been around for a while. I searched this board and found a request (Msg.Id 14159) for how to use a variable in the TABLECOUNT() function. No one replied to this message. I guess it can't be done.

          Thank you

          Dick

          Comment


            #6
            RE: Calculated fields on a form

            Peter,

            I tried both the methods you suggested and neither worked. If I go to the next or previous record the date change is there and the recalculations performed on those records. Also, when I return to the original record the recalculation is done. I must be missing something simple, maybe a command which recalculates the form/record the same as happens when you move to another record. Does this make sense?

            Thank you

            Dick

            Comment


              #7
              RE: Calculated fields on a form

              This may not be the best solution, but if it works, what the heck. Why not just put in a ui_freeze, fetch_next, fetch_prev, ui_freeze(.f.). Someone else would probably have a better idea but this might at least work.

              Russ

              Comment


                #8
                RE: Calculated fields on a form

                Dick, don't give up on tablecount().

                Take a look at Form1 after unzipping the attachment to a separate folder. Don't mix it with your development work.

                The filter expression used tablecount() required a bit of prodding and cajoling, but it works out ok in the end.

                -- tom

                Comment


                  #9
                  RE: Calculated fields on a form

                  Tom

                  Thank you for your reply. I will look at it today. I have been on the road and this is the first opportunity I have had to get back to the message board.

                  Thank you again,

                  Dick

                  Comment

                  Working...
                  X