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

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

    Hello there,

    I have been working on creating a message box that comes up after a user has changed the values in the form. I would like to have a dialog box come up to ask up to ask the user if they want to save the record or not. If the user wants to saves then it commits the save and if it doesn't then it changes it back to the original values of the fields (if they are editing a record) or reset the new record.

    I thought I could do this by creating an action script on the cansave event. I have set a message dialog box that asks the user if they want to save. If they click OK then I have an action script that saves the record. If they click cancel I have set an action script that will cancel changes.

    Saving the record is fine, but when I use the cancel script, it cancels but comes with an error message to say that "The object "Analysis Form" does not exist. " where Analysis Form is the form that the user is entering data.

    I am wondering what I am doing wrong, and what can I do to resolve this error?

    Any help would be greatly appreciated.

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

    Originally posted by Tanman View Post

    ''Analysis Form"
    Rename your form to Analysis_Form...

    AlphaFive converts spaces of form names to _ character.

    hope others will chime in to explain it better

    alpha has this feature built-in...
    try opening a form with records and without cansave record codes
    edit a record
    try to close the form, it shows the "Save change in progress?" dialog with "Yes, No Cancel" buttons
    Last edited by fddizon; 03-31-2008, 07:02 PM.
    Francis

    Comment


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

      Thanks for the reply Francis,
      Thats works great when the form is closed, but what happens when the user clicks the next button or back or forward after making some changes. I found that there is no prompt there to ask if the record needs to be saved.

      I read through the help files and wonder if this is in the CanSave and CanChange events.

      I was thinking that under each one of those events I create a Message box (using the wizards) that has the yes and no responses to them and attaching the save record or cancel changes scripts to it.

      For those that have done a dialog box before any type of data change, I would be interested as to what how you did it.

      Thanks,

      Wei-Yen

      Comment


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

        Wei,

        try putting this code to your forms cansave event
        Code:
        if topparent.mode_get() = "CHANGE" .or. topparent.mode_get() = "ENTER" then
        	response = ui_msg_box("Save", "Do you want to save changes?",UI_QUESTION_SYMBOL+UI_YES_NO)
        	if response = UI_YES_SELECTED then
        	    topparent.Commit()
        	else
        		topparent.cancel()
        	end if
        end if
        hope this helps...

        :)
        i haven't tried looking for this if there is a sample in the code archive section of a "standard working form model" that has these essential features of a data entry form before it is deployed to end users.

        i hope someone from our gurus here will share a standard working model of a data entry form in the archive section...
        Francis

        Comment


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

          Francis and Wei-Yen,

          You don't need to specify topparent.commit() in the CanSave event because you are already in a saving procedure. You just need to let the event happen by do nothing as a result of your test. To stop the save, ie cancel the event use cancel(). Then if you want to also cancel the changes made in the form add topparent.cancel().
          Code:
          if topparent.mode_get() = "CHANGE" .or. topparent.mode_get() = "ENTER" then
              response = ui_msg_box("Save", "Do you want to save changes?",UI_QUESTION_SYMBOL+UI_YES_NO)
              if response = UI_YES_SELECTED then
                  'donothing - since  this is the cansave event doing nothing just allows A5 to 
                  '            continue with the save
              else
                  cancel()     'cancel the save event
                  'If you want to leave the edited values in place for possible correction
                  'comment out or remove the next line
                  topparent.cancel()  'cancel changes to the record. ie return to original values            
              end if
          end if
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


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

            tim,

            you are right. thanks for the correction.

            Code:
            if topparent.mode_get() = "CHANGE" .or. topparent.mode_get() = "ENTER" then
            	response = ui_msg_box("Save", "Do you want to save changes?",UI_QUESTION_SYMBOL+UI_YES_NO)
            	if response = UI_YES_SELECTED then
            	    ui_msg_box("Message", "Your record has been successfully saved.", UI_INFORMATION_SYMBOL+UI_OK)
            	else
                       'wei should use this since he is navigating out from the edited record
            	    topparent.cancel()
            	end if
            end if
            Francis

            Comment


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

              Tim,

              can you post one of your simple table with data entry form here in this thread? (if its not too much) a copy that you have been deployed to end users. i am sure, a lot of us will benefit from your example...

              thanks
              Francis

              Comment


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

                That still doesn't cancel the changes. In any CanWhatever event if you don't use cancel() then the event procedes. In this case it is the save event so when you navigate to the next record without canceling the event with the cancel() function the save still proceeds. The topparent.cancel() now applies to the record you just navigated to.
                Tim Kiebert
                Eagle Creek Citrus
                A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                Comment


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

                  Tim,

                  another mistake...lol

                  thanks
                  Francis

                  Comment


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

                    Originally posted by fddizon View Post
                    i hope someone from our gurus here will share a standard working model of a data entry form in the archive section...
                    Originally posted by fddizon View Post
                    Tim,

                    can you post one of your simple table with data entry form here in this thread? (if its not too much) a copy that you have been deployed to end users. i am sure, a lot of us will benefit from your example...

                    thanks
                    Francis, I am afraid I don't belong to that group of gurus you mentioned :)so I don't really have a standard premade form that I regularly use. If I want any kind of control over data entry I usually lock the form down by removing the menu and the toolbar and then placing my own nav/save/enter buttons. That is probably more than some want to do. Having such an example is a good idea though and if no one else jumps in or points us to one already here somewhere I will put it on my todo list. I know I have seen various examples of data entry control on my travels through this forum and probably on Dr Waynes learningalpha site but don't have any specific links to point you to. Actually, finding stuff on this forum is MikeC's specialty so maybe he will come up with something.;)
                    Tim Kiebert
                    Eagle Creek Citrus
                    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                    Comment


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

                      Tim, Francis, and Wei-Yen,

                      This addresses the situation of when nothing has been committed yet as any topparent.cancel() only cancels those data entries that have not been committed. Many times (actually in my case Most times!) the entries on a form have to be committed prior to navigating say to find a record--but then if you wanted to "cancel" the entire event, what then?!

                      So far I have only found two ways around this scenario.

                      1...create a delete operation(s) for the parent and or child record(s) involved

                      2...use the function .RECORD_DATA_GET() which takes the contents of the record and places it into a Blob variable Before any part of a record is changed and then use .RECORD_DATA_SET() if you wanted the record to revert back to its original state.

                      The latter, for me, is much preferred.

                      Is there any other way to revert back to original data once changed (and committed) that is used?? Always nice to know of other ways to do things, especially if there are better ways! :)
                      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


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

                        Hi Mike,

                        Thanks for your input...I was curious as to how would it look. Would it look like this:
                        Code:
                        RECORD_DATA_GET()
                        if topparent.mode_get() = "CHANGE" .or. topparent.mode_get() = "ENTER" then
                            response = ui_msg_box("Save", "Do you want to save changes?",UI_QUESTION_SYMBOL+UI_YES_NO)
                            if response = UI_YES_SELECTED then
                                'donothing - since  this is the cansave event doing nothing just allows A5 to 
                                '            continue with the save
                            else
                        .RECORD_DATA_SET()values            
                            end if
                        end if
                        Thanks Mike for your input on this. :)

                        Comment


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

                          Wei-Yen,
                          Quite a bit different actually. In my case I know that parts of the record have been saved already. So to "cancel" or revert things back to where they were to begin with I have used this method.

                          The following is but one way to do this.

                          1...Create a shared (session) or global logical variable called svBlob
                          2...On the OnInit event of a form place the script
                          Code:
                          svBlob=.T.
                          3...On the OnActivate event of the same form place this script.
                          Code:
                          if svBlob=.T. then
                            dim tbl as p
                            dim rec_data as b
                            tbl=table.current()
                            rec_data=tbl.record_data_get()
                            svBlob=.F.'prevents this code from running again once the form is open
                                            'setting the Blob variable does not work on the OnInit event
                          end if
                          The above script basically has to be done prior to any changes made to the record...As the Blob could not be set using the OnInit event of the form I used the OnActivate and with the svBlob logical variable it only allows the Blob to be set once when a form is opened.

                          4...And this is then placed on the Cancel button's OnPush event.
                          Code:
                          if svBlob=.F. then  'this just makes sure that the Blob was set as the 
                                                   'only way it can be .F. is after the Blob gets data.
                           dim tbl as p
                           tbl=table.current()
                            if rec_data<>"" then
                              tbl.change_begin()
                              tbl.record_data_set(rec_data)
                              tbl.change_end(.t.)
                            end if
                          end if
                          
                          topparent.refresh_layout()

                          I am sure there are ways to make this a bit more streamlined and all but as it works I have not felt the need yet to do so.
                          Last edited by MikeC; 04-07-2008, 08:57 PM.
                          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


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

                            Thanks Mike,

                            I'll give that a go.

                            Comment


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

                              Originally posted by MikeC View Post
                              Tim, Francis, and Wei-Yen,

                              This addresses the situation of when nothing has been committed yet as any topparent.cancel() only cancels those data entries that have not been committed. Many times (actually in my case Most times!) the entries on a form have to be committed prior to navigating say to find a record--but then if you wanted to "cancel" the entire event, what then?!
                              I am trying to understand this better. If you move off of the current record, which record are your reverting?

                              I have used the following code on the CanSave and CanExit event to give the user the option of going ahead with saving (Selecting 'Yes'), losing the changes (selecting 'No'), or canceling to correct the entry (selecting 'Cancel'). The 'No' doesn't seem to work if you don't restrict navigation, so I need to figure that out.

                              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()
                                  	elseif ans = UI_CANCEL_SELECTED then
                                  		'Cancel selected
                                  		cancel()
                                  	end if
                              end if
                              This brings up another question I have. You can cancel the changes to a record based on one table, but what about a set? It seems Alpha saves the parent record and each record in the child table as you go. How can you undo these types of records?

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

                              Comment

                              Working...
                              X