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

Methodology of creating a way to cancel changes to a record?

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

    #16
    Re: Methodology of creating a way to cancel changes to a record?

    Hmmm, that was one thing that I failed to mention. My form is based off a set, so I will end up with that type of problem right?. I'll check Mike's solution first.

    Comment


      #17
      Re: Methodology of creating a way to cancel changes to a record?

      Wei-Yen and Dan,

      If any record has been saved (committed) a topparent.cancel() has no affect on it...a cancel of any kind is only for records entered but not yet committed. It is for this reason I pointed out and gave an example of what could be done in a case in which records had been already committed, but you wanted the record to revert back to its original state. The example I gave could be used for a child record. If a parent and child both had been saved then my example as given would not work. But the concept could be expanded to accommodate this scenario as well....just a bit more scripting and planning involved.

      The same sort of script could be placed on the parent as well. I imagine that it would be possible to cancel in this way just the child, just the parent (if no child present, or both -- cancelling the child first (reverting back to original data) and then once back on the parent doing the same for it.

      I was hoping that others had figured out a different way or perhaps I had missed a function of some kind to accomplish this but it appears not. But this actually is not all that bad to accomplish as there is not that much script to write--just have to have the concept in mind when doing it is all....using this script is just reverting the data values back to a previous state in which they were saved with the <table>.record_data_get() function.
      Mike
      __________________________________________
      It is only when we forget all our learning that we begin to know.
      It's not what you look at that matters, it's what you see.
      Henry David Thoreau
      __________________________________________



      Comment


        #18
        Re: Methodology of creating a way to cancel changes to a record?

        Here is what the help file says...
        Alpha Five features advanced relational capabilities. In Alpha Five, you can combine tables into a set, which are logically related tables linked together according to a specified criteria. For example, you might link a table of invoice orders to a table of customer names.

        Using sets, you can search, report, and view data from component tables, as if they were a single table. A set reduces the storage of redundant information, making your data easier to update, less prone to errors, and more efficient. Sets also offer options not available with single tables.

        In almost every case, Alpha Five treats sets exactly like tables. You can create layouts and perform and save operations for a set. When entering data into a form designed for a set, the information is automatically placed into the correct table along with the necessary linking information.
        In reading that, I thought great, I can just do a ':formname.cancel()' and undo any changes that are made to the set, if the user decides not to save. Unfortunately, that is not the way it seems to work. This is one thing I always ran into with Access and was hoping Alpha would be different. But it looks like it has the same quirk. It saves (commits) the 'parent' record and each 'child' record when moving focus from one to the other, which leaves the programmer to figure out how to undo. That's not very intuitive in my mind. I would like to know how the folks at Alpha would address this.

        btw; I got the code to work for what I posted earlier. Just change topparent.cancel() to topparent.cancel(.t.). This works for a form based on a single table. Here it is...
        Code:
        dim res as C
        	dim ans as N
        	res=parentform.Mode_Get()
        	if res = "Change" then
        		ans = msgbox("Save?","You have made changes, do you want to save them before leaving?",UI_ATTENTION_SYMBOL+UI_FIRST_BUTTON_DEFAULT+UI_YES_NO_CANCEL)
        		if ans = UI_YES_SELECTED then
        			'Yes selected,
        			'do nothing, record saved automatically
        		elseif ans = UI_NO_SELECTED then
        			'No selected
        			topparent.cancel(.t.)
        		elseif ans = UI_CANCEL_SELECTED then
        			'Cancel selected
        			cancel()
        		end if
        	end if
        end if
        Thanks, Dan
        - Dan Hooley
        - Custom Desktop or Web database development -

        Comment


          #19
          Re: Methodology of creating a way to cancel changes to a record?

          Dan,
          I'm not a guru here by any means but here is my take on things....


          I can just do a ':formname.cancel()' and undo any changes that are made to the set, if the user decides not to save
          This is very true--a cancel works on UNSAVED data.

          It saves (commits) the 'parent' record and each 'child' record when moving focus from one to the other, which leaves the programmer to figure out how to undo. That's not very intuitive in my mind.
          This makes perfect sense if you look at it in that how can an unsaved record (parent in this case) have a child record??? Not possible in my mind. How can something be linked to anything else if it does not exist yet is another way to look at it.

          If the latter is troublesome then do as you have for the single table for the parent and then for the child. That is, test for data that is about to be saved and make a decision then as to what to do.

          The main thing is to be clear in the fact that a cancel ONLY works for an unsaved record...after being saved either my method or a delete operation would have to be used....still waiting (hoping) for another alternative but have a feeling these are the only two options. And really they are not that hard to incorporate.
          Mike
          __________________________________________
          It is only when we forget all our learning that we begin to know.
          It's not what you look at that matters, it's what you see.
          Henry David Thoreau
          __________________________________________



          Comment


            #20
            Re: Methodology of creating a way to cancel changes to a record?

            Originally posted by MikeC View Post
            Dan,

            This makes perfect sense if you look at it in that how can an unsaved record (parent in this case) have a child record??? Not possible in my mind. How can something be linked to anything else if it does not exist yet is another way to look at it.
            That is true for a new record being entered, but what about editing an existing record. An existing parent record could have multiple child records (as in an invoice), and the user could make changes to the parent record and/or any of child records in a form base on a set and doesn't know (nor should he have to) that he is affecting several tables and therefore needs to make a decision about saving (and undoing) for each table affected.

            All I am saying is that Alpha does not treat the data on such a form the same as a form based on a single table, as it relates to saving and undoing changes. And I wish they did.

            I am confident there is an affective way of handling this, I am just not sure how to do it in a form based on a set. Hopefully someone does and can help me out.

            Thanks, Dan
            - Dan Hooley
            - Custom Desktop or Web database development -

            Comment


              #21
              Re: Methodology of creating a way to cancel changes to a record?

              Hi Dan,
              That is true for a new record being entered, but what about editing an existing record
              Good point!

              But I think this has almost gone into a rhetorical line of thought as Alpha treats any record the same whether it is from a single table or a set of tables...If a record is committed it can no longer be cancelled. If you don't want a record saved then trap the event and cancel the save. If nothing has been changed in a parent (still in view mode) then navigating to a child record has the same effect as going to a single table...if nothing is changed in the child table then there is nothing to be saved (or cancelled) and you can go back to the parent record without having a commit and no need to cancel anything as nothing was changed.

              I guess I am having a hard time understanding the problem. It is only when a change has happened and must be committed before navigating away from the record that doing anything regarding a cancel even has to be considered....how would you want it any different??? I wouldn't. If a change is made and is not saved ...and you are allowed to navigate away from the record and possibly never saving it that can cause big problems. I much prefer the way it is now. And as it has been this way for who knows how long Alpha would have to consider many things before changing such default behavior so as not to break most likely every application created....which they could do I guess with an option and that would be something for the Wishlist Forum.

              :) I am just hoping that the main thing that comes out of this discussion is the understanding that a cancel cannot happen if a record has been committed...and that there are methods to either prevent the commit, return the record to a prior state, or to create a delete operation when such commits end up creating blank records.
              Mike
              __________________________________________
              It is only when we forget all our learning that we begin to know.
              It's not what you look at that matters, it's what you see.
              Henry David Thoreau
              __________________________________________



              Comment


                #22
                Re: Methodology of creating a way to cancel changes to a record?

                Hi Mike,

                I think I understand the concept of the cancel function and that when a record is committed it can no longer be canceled. I have no problem with that. I think I can get what I want on a form based on a single table. What I am trying to figure out is how to do the same thing with a form based on a set. The user sees the whole form and the data on the form as an entry/edit form even though it is in fact data from different tables and I want a way to allow them to add/edit any data on the whole form and still be able to cancel the whole thing.

                Take the Alpha Sports App invoice form: see thumbnail...

                Open up Alpha Sports and open the invoice form,

                on any existing invoice; add a credit card number to the credit card field,
                then move down and add a line item to the invoice,
                then move up and edit the price on an existing line item...

                ... now cancel all of the above... how do I do it?

                that is what I am talking about.

                Dan
                - Dan Hooley
                - Custom Desktop or Web database development -

                Comment


                  #23
                  Re: Methodology of creating a way to cancel changes to a record?

                  Originally posted by dhooley View Post

                  ... now cancel all of the above... how do I do it?
                  I think you are going to have to go back to Mike's suggestion of <TBL>.RECORD_DATA_GET() and capture the record data for each table in the set. If the user decides to cancel the whole edit, commit their pending changes and then write the original values back as changes to each table.

                  It won't be as much work as it might seem because you can just reference the tables in the set with

                  tbl=table.current(1)
                  tbl=table.current(2)
                  ....

                  Of course you will probably want to use separate table pointer variable names and blob variable names for each table.
                  There can be only one.

                  Comment


                    #24
                    Re: Methodology of creating a way to cancel changes to a record?

                    Hi Dan,
                    Not knowing the exact setup in AlphaSports I would first try the approach I iterated in post #13.

                    I have to leave pretty soon but will attempt what you described with AlphaSports when I return and see if my methodology works in that case or if a different method needs to be used. It will be a few hours before I get back to this--maybe even later tonight.
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment


                      #25
                      Re: Methodology of creating a way to cancel changes to a record?

                      So far my attempts in AlphaSports is not working--something else may be going on but too tired to worry about it tonight! Maybe someone else can chime in who usually is up when I am asleep!!
                      Mike
                      __________________________________________
                      It is only when we forget all our learning that we begin to know.
                      It's not what you look at that matters, it's what you see.
                      Henry David Thoreau
                      __________________________________________



                      Comment


                        #26
                        Re: Methodology of creating a way to cancel changes to a record?

                        Mike, I appreciate all your hard work. This is something that I have been wanting to get figured out for some time, and am surprised that it seems no one has a solution.

                        Does anyone give there users the option to cancel??

                        Maybe we should start a new thread... in maybe Database Design or Wishlist??

                        Dan
                        - Dan Hooley
                        - Custom Desktop or Web database development -

                        Comment

                        Working...
                        X