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

How to put table in enter mode and cancel?

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

    How to put table in enter mode and cancel?

    Hello, again calling for help. I really cannot make it up from the help-files and the threads on the board..

    simple setup:

    1 table
    form with "new customer" button on it
    user presses the button -> form comes up to enter new record

    i want to put the table in enter mode and activate the first field ("name")
    i let the user fill in the fields
    on the form there are 2 buttons: save and cancel
    if user pushes save record is saved and form is closed
    if user pushes cancel record is cancelled and form is closed


    i have put this on the "new customer" button push event:

    Code:
    	topparent.new_record()
    	tbl.enter_begin()
        name.activate()
    here i get an error saying "table already in enter mode", so i only need to do topparent.new_record() ?

    on the cancel button i have put:

    Code:
    cancel(.t.)
    topparent.cancel(.t.)
    i still dont understand the diference between the two....

    i just want to have the table put in "enter mode" when pushing the new customer button and cancel this record "in creation" when the user exist the app or presses the cancel button.

    thank you for the help,

    Olivier

    #2
    Re: How to put table in enter mode and cancel?

    Olivier, is there some reason you're trying to do this in xbasic instead of using Action Scripting?

    I recommend Dr. Wayne's "Xbasic for Everyone" if you want to learn xbasic.

    Here are some fundamentals if you want to continue trying to write xbasic code:

    - every time a form opens the tables supporting that form are opened automatically
    - if your table is empty and you open a form based on that table it will open in ENTER mode automatically
    - if a form is already in enter mode you cannot run a script to place it enter mode. The error message you're getting suggests that this is what's happening. So have your script test the mode of the form before beginning a new record. if mode is VIEW then begin the ENTER, if it's ENTER or CHANGE don't.
    - xbasic has commands that let your script talk to the objects on the form (emulating a user at the keyboard), and it also has commands that let your script talk directly to the table beneath the form. Don't mix these approaches in the same script. Your script should either manipulate the table beneath the form and then update the display when it's finished, OR it should manipulate the objects on the form, in which case no refresh is needed. Don't mix these approaches in a single script.

    topparent.new_record() is a method of the form object. It will begin a new record if the form was in VIEW Mode when it executes. The user can fill in the field values using objects on the form. This method should be used when you want the user to supply the field values for the new record.

    tbl.enter_begin() is a method of the table object. If "tbl" has been correctly initialized as a pointer to the current table it will place the table in ENTER mode so that your script could then populate the fields for the user. Again it will work only if the table is in VIEW mode. Because this is manipulating the table beneath the form the user cannot enter field values, they must be scripted. This method should be used when you want your script to begin a new record, populate its fields for the user, and then save it. All of which requires many other command statements.

    -- tom
    Last edited by Tom Cone Jr; 07-29-2008, 06:50 AM.

    Comment


      #3
      Re: How to put table in enter mode and cancel?

      thank you Tom,

      I have managed to get it working by putting only

      Code:
      topparent.new_record()
      name.activate()
      on the button.push

      on the cancel button i have put:

      Code:
      topparent.cancel()
      this works and no records is "left" without any fields filled in when the user presses cancel.

      but when i click on the A5 button "design mode" the record is not cancelled and i have a record with no fields filled in in the database ?

      I have tried to put

      topparent.cancel() in the OnExit but that did not work and if i check the mode status with this:

      Code:
      dim tbl as P
      dim status as N
      tbl = table.current()
      
      status = tbl.mode_get()
      the mode is already "view" (0) in the OnExit as well as in the CanExit and OnDeactivate events....

      So where do I have to put the cancel command in this case ?

      thank you, Olivier

      Comment


        #4
        Re: How to put table in enter mode and cancel?

        but when i click on the A5 button "design mode" the record is not cancelled and i have a record with no fields filled in in the database ?
        This wasn't part of your original question and is not a common happenstance for the end user. Unless the end user has the development version they cannot switch to design mode. If they do they should know enough not to do it while in the middle of data entry/record creation.
        There can be only one.

        Comment


          #5
          Re: How to put table in enter mode and cancel?

          Oliver,
          There is no reason to fret over this issue since the placing the form into design mode is not something that is going to happen when the database is in it's operational condition, right?
          Mike W
          __________________________
          "I rebel in at least small things to express to the world that I have not completely surrendered"

          Comment


            #6
            Re: How to put table in enter mode and cancel?

            that is true, maybe i am making things complicated for myself, thanx....

            to put the table into edit mode i assume i follow the same strategy ? Now i use this.allow_change(.T.) or should i write topparent.allow_change(.T.) ?

            -- Olivier

            Comment


              #7
              Re: How to put table in enter mode and cancel?

              Originally posted by olivier View Post
              to put the table into edit mode i assume i follow the same strategy ? Now i use this.allow_change(.T.) or should i write topparent.allow_change(.T.) ?

              -- Olivier
              Always depends on the context.

              On a button topparent.allow_change(.T.) would allow changes on the form.

              this.allow_change(.T.) would probably try to allow changes on the button and likely result in an error.

              Responding to a form event (like onfetch) , this.allow_change(.T.) could be appropriate.
              There can be only one.

              Comment


                #8
                Re: How to put table in enter mode and cancel?

                [QUOTE]I have managed to get it working by putting only

                Code:
                topparent.new_record()
                name.activate()[/
                QUOTE]


                Actually, these don't directly put the table in ENTER mode. They put the FORM in ENTER mode. Because the form goes into ENTER mode the table that's bound to it will also. But it's important to keep these separate in your mind. You're using form methods, not table methods. You should begin to think in terms of code which talks to the table beneath (supporting) the form, and code which talks to the form itself. Understanding this concept and mastering the syntax to do each is key to writing successful xbasic scripts.

                Comment


                  #9
                  Re: How to put table in enter mode and cancel?

                  OK, i think i am seeing the light.... thank you guys :)

                  Comment


                    #10
                    De Facto Best Practices #1?

                    Originally posted by Tom Cone Jr View Post
                    Olivier, is there some reason you're trying to do this in xbasic instead of using Action Scripting?

                    I recommend Dr. Wayne's "Xbasic for Everyone" if you want to learn xbasic.

                    Here are some fundamentals if you want to continue trying to write xbasic code:

                    - every time a form opens the tables supporting that form are opened automatically
                    - if your table is empty and you open a form based on that table it will open in ENTER mode automatically
                    - if a form is already in enter mode you cannot run a script to place it enter mode. The error message you're getting suggests that this is what's happening. So have your script test the mode of the form before beginning a new record. if mode is VIEW then begin the ENTER, if it's ENTER or CHANGE don't.
                    - xbasic has commands that let your script talk to the objects on the form (emulating a user at the keyboard), and it also has commands that let your script talk directly to the table beneath the form. Don't mix these approaches in the same script. Your script should either manipulate the table beneath the form and then update the display when it's finished, OR it should manipulate the objects on the form, in which case no refresh is needed. Don't mix these approaches in a single script.

                    topparent.new_record() is a method of the form object. It will begin a new record if the form was in VIEW Mode when it executes. The user can fill in the field values using objects on the form. This method should be used when you want the user to supply the field values for the new record.

                    tbl.enter_begin() is a method of the table object. If "tbl" has been correctly initialized as a pointer to the current table it will place the table in ENTER mode so that your script could then populate the fields for the user. Again it will work only if the table is in VIEW mode. Because this is manipulating the table beneath the form the user cannot enter field values, they must be scripted. This method should be used when you want your script to begin a new record, populate its fields for the user, and then save it. All of which requires many other command statements.

                    -- tom
                    Tom,
                    As I was searching for help on a problem here, I came across your comments here and they struck me as profound on a couple of levels.
                    1. I am trying to understand what A5 best practices are - and it seems this is one: don't mix form and table actions in the same script. I like it!
                    2. Is there a link to that book with affiliate tracking you might be willing to supply? I'm gonna get it!
                    Thanks, Scott

                    Comment


                      #11
                      Re: How to put table in enter mode and cancel?

                      maybe here
                      http://www.libertymanuals.com/xbasic...eryone-v8.html

                      Comment


                        #12
                        Re: How to put table in enter mode and cancel?

                        Here is a link to Peter Wayne's xbasic for everyone book....and on the webpage is another link to where you can purchase it.

                        http://www.imakenews.com/alphasoftwa...x000233923.cfm
                        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

                        Working...
                        X