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

Check zero value before being allowed to close form

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

    Check zero value before being allowed to close form

    I want to prevent the form from being closed if the value in a calculated field is not zero

    I have a form that is used to enter historical data into a table from paper copies of our Sales Slips
    I have set up two calculated fields on that form that shows the variance between what the form has calculated and what the user has entered. I want the variance to be zero in both fields before I allow the form to be closed and the record saved.

    I have looked at form properties and form control properties but cannot find a way to verify the calculated field is zero before closing the form. I am now thinking I need to use a script. But I do not know how to do that. Do I need to use a script to do what I want or is there a way to do this from the Action Script menues?

    If I do need to create a script where do I start? I want the script to do this:
    Check the values in the two calculated fields on the form
    If the value in both fields is zero than allow the user to proceed as normal (close form)
    If the value is not zero in either field than display an error message and put the user back into the form to make corrections until the values are zero.

    Do I put this script on the "OnExit" event? or the "CanExit" event? or somewhere else?

    I've never done scripting in A5 before.

    Thank you,
    Sean

    #2
    Re: Check zero value before being allowed to close form

    I have not tested this, but where I would start.

    on can exit, I would get the field value into a variable and test that it is or is not zero, then put the focus back to a field where it can be corrected or allow the exit(which is "do nothing")

    you can do most of this with a genie.
    varsettofield.pngvarsettofield2.png

    Comment


      #3
      Re: Check zero value before being allowed to close form

      put this in the form's canexit event

      if somevalue <> 0
      cancel()
      end if
      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


        #4
        Re: Check zero value before being allowed to close form

        Sean,

        why two calc fields to show a single variance value?

        Please clarify some things:

        1) when you say you have two calc fields, are these table fields for which you've defined calc expressions in field rules, or are these "calculated display" fields defined in the form layout but not present in your table?

        2) do you mean to say you have two calc fields and you want a third (computed) value to be zero, or do you want (as you have written) each of the two calc fields in your form to be zero.

        3) examine the objects displaying the two calc values in your form layout. What is each object's official "name"?

        4) in your own words describe how you would use the two calc values in your form layout to arrive a computed value of zero?

        Any chance you can post a sample database, containing the tables supporting your form and their accompanying dictionaries?

        -- tom

        Comment


          #5
          Re: Check zero value before being allowed to close form

          Tom,

          I have two calc fields that calculate two different values. One calculates the difference in the Materials values the other the difference in the Total values. I set these up on the entry form as an aid to catch typos. I look at them when I review the records but now I want to automate the entry a little more to help control mistakes by the entry person.

          Answer 1) These are form fields only. I did not set these up in the table.

          2) I want each calculated variance field to be zero. If something other than zero is in the variance fields then there is a typo somewhere.

          3) "cmtrlvariance" is the name for the field that shows the variance between the "Materials" field (entered by the user)and the "Calculated Materials" field (calculated from the values entered into the separate category fields by the user)

          "cvariance" is the name of the field that shows the variance between the "Total" field (entered by user) and the "Calculated Total" field (calculated from the Materials,Tax,and Labor fields entered separately by the user)

          4) for cmtrlvariance - take the values entered into the separate category fields (Unit,Options,Chimney, etc.) and sum them and place in the field named "cmaterials". Subtract cmaterials from the value entered into the field named "materials". If the value does not equal zero there is an entry error in one of the amount fields.

          for cvariance - take the values entered into the separate entry fields (Materials, Labor,Tax) and sum them and place in the field named "ctotal". Subtract ctotal from the value entered into the field named "total". If the value does not equal zero there is an entry error in one of the amount fields.

          I don't think I can figure out how to send a copy. I need to figure that out later. I'll need to remove all the private data and I'm not yet sure how I'll do that.

          Thanks for your help

          Sean

          Comment


            #6
            Re: Check zero value before being allowed to close form

            Thanks Al,

            I looked at that but I could not figure out how to "test that it is or is not zero"

            Comment


              #7
              Re: Check zero value before being allowed to close form

              Originally posted by martinwcole View Post
              put this in the form's canexit event

              if somevalue <> 0
              cancel()
              end if
              This is done with a script? How do I get a script to fire on a form event? Do I enter this script in the genie? or do I store the script somewhere and then refer to it?

              Sean

              Comment


                #8
                Re: Check zero value before being allowed to close form

                Sean,

                Assuming the two calc display fields are numeric data, something close to this should do the trick

                In the CanExit event for the form:

                Code:
                if calc->cmtrlvariance <> 0 .or. calc->cvariance <> 0 then
                    msgbox("Oops","Your transaction is not in balance, check your variance values and correct before closing the form.")
                    cancel()
                end if


                We can't see the entire data entry sequence. The solution above should solve the immediate problem but it would not prevent the user from entering incorrect data for two separate transactions back to back. why? because they wouldn't try to close the form after each transaction so the CanExit wouldn't fire until they try to close the form after the 2nd transaction. Is this clear?

                You probably need to think more carefully about when you want this type of validation to occur, limiting it to attempts to close the form may not cover all the situations you may need.
                Last edited by Tom Cone Jr; September 03, 2013, 09:00 AM.

                Comment


                  #9
                  Re: Check zero value before being allowed to close form

                  [ deleted duplicate ]

                  Comment


                    #10
                    Re: Check zero value before being allowed to close form

                    Sean, put Tom's code in the canexit event for the form. Action scripting is not needed. In design mode, at the top of the screen, where you see Form, right click and you will see many form events - one of them is CanExit

                    Tom, do you think this might be better handled in the cansaverecord event in field rules?
                    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: Check zero value before being allowed to close form

                      Martin, I'm not sure. That works well for a data entry form based on a single table, but its beginning to sound like he's got a set based form, that probably includes multiple child table records. what's needed is an event that fires before the user can leave the current transaction. -- tom

                      Comment


                        #12
                        Re: Check zero value before being allowed to close form

                        Thanks guys. Yes, this form is based on a set. And I probably should consider putting this kind of thing in the table field rules. I'll start messing around with that idea. In the meantime this solution looks like I might at least be able to show a warning message if they try to close the form before making sure the numbers are correct. I'm still a little unsure of how to get this script into the form but at least I now have a clue. I'll experiment and see if I can figure it out. It's about time I learned how to do some simple Xbasic scripts instead of just using the Active Script genies.

                        Thank again.
                        Sean

                        Comment


                          #13
                          Re: Check zero value before being allowed to close form

                          Sean,

                          You may need to re-think the concept of a "record". In your first post it sounds like you use that term to refer to the entire transaction. In databases like Alpha Five the term has a very different meaning. In your set based form each "transaction" probably has a single "record" entered to the parent table in your set, and multiple "records" entered into the linked child table. The parent table record will be saved as soon as editing a new child record begins. If you are entering child table records through an embedded browse each row gets saved when the user navigates to a different row, or clicks on a field in the form outside the browse object. All of this can be managed but its not particularly easy, and is impossible for us to specify for you, given the limited amount of information you've furnished and the absence of a working sample.

                          Comment


                            #14
                            Re: Check zero value before being allowed to close form

                            Maybe a picture of the form will help?Transaction Form.png

                            Comment


                              #15
                              Re: Check zero value before being allowed to close form

                              In this case the set consists of two tables, the Transaction table and the Customer table. The set is used only to link the customer name and number to the transaction entry. I'm sure there are times when I am using multiple records from a child table but in this case each time I enter a transaction with this form I'm entering a new record into the Transaction table. The customer record is not added as it must already exist before the Transaction can be entered. In our terminology the Transaction record represents a single sales slip.

                              Comment

                              Working...
                              X