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

Getting around a A5 system message

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

    Getting around a A5 system message

    In a situation where there are many tables related to a single parent, and when it is not practical to use a set for many reasons, my code is designed to delete all child records and then delete the parent.

    It works fine, thanks to Selwyn's help! But there is one little glitch. (Isn't there always?)

    At the start of the script, I display this message:
    "Are you sure you want to delete this person and all related records?"

    The script properly deletes all the child records and then executes this code:

    parentform.delete_record()
    topparent.resynch()

    The problem is, as is explained in the docs, "The <OBJECT>.DELETE_RECORD() method displays a confirmation message box and then deletes the current record in the layout after."

    That second confirmation message is not needed and is also confusing, since the user has already given an 'ok' to delete the records

    Anyone have a workaround?

    (As an aside, that topparent.resynch() gets rid of the 'phantom record' problem when there are no more records in the table. There's been lots of discussion about that issue. Again, thanks Selwyn.)
    Richard

    #2
    Without dialog

    <tbl>.delete() should do it for you

    - John O
    John Oesterle
    ToolBytes, LLC

    Comment


      #3
      Richard, John is right. One further note. Read the help file on proper usage of the <tbl>.delete() method. The table must be placed in change mode before this method will work. -- tom

      Comment


        #4
        This may not be to applicable in your situation since you've already deleted the child records but it does make sense if done before anything is deleted. (In other words, this idea is more for others who are reading this.)

        You might want to consider leaving the message there and changing your first prompt so the second one doesn't seem quite so confusing. I've started doing this because of the number of people who used to say things like, "But I didn't really want to delete it."

        Now my first message will often say something like this just to clarify exactly what is being deleted:
        Ready to delete:
        Owner: Joe Btfsplk
        Address: Route 1, Dogpatch, USA

        <Yes> <No>

        If they answer 'Yes' then the simple system prompt (something like "OK to delete this record?") pops up to give them one last chance.

        Since I've implemented this "multiple chance" process, nobody has come back and said, "Oops, I deleted something by mistake. How can I get it back?"

        Comment


          #5
          Thanks, guys! Once again you come through in a flash!

          And that's a great suggestion, Cal.
          Richard

          Comment


            #6
            Okay, still got a problem, but perhaps (maybe, hopefully, prayerfully....whateverfully) it is the last!

            Here is the code:

            'Delete all child records associated with the current Personal Info record

            dim ptr as P
            dim name as C
            dim tbl as P
            dim tblhold as P
            dim fld as P
            Dim i as N

            'Set up parameters for Table Personal Info
            tblhold = table.current()
            fld = tblhold.field_get("Full_name")
            name = fld.value_get()

            'Second Delete Warning Message
            DIM SHARED Second_Delete_Warning_result as N
            DIM SHARED Second_Delete_Warning_YES_Button as L
            DIM SHARED Second_Delete_Warning_NO_Button as L
            Second_Delete_Warning_YES_Button = .F.
            Second_Delete_Warning_NO_Button = .F.

            title_var = "Are you ready to delete all information about..."
            message_text_var = name
            Second_Delete_Warning_result=ui_msg_box(title_var,message_text_var,UI_YES_NO+ UI_FIRST_BUTTON_DEFAULT+ UI_NO_SYMBOL)
            'Test to see which button on the message box was pressed....
            SELECT
            CASE Second_Delete_Warning_result = UI_YES_SELECTED
            Second_Delete_Warning_YES_Button= .t.
            CASE Second_Delete_Warning_result = UI_NO_SELECTED
            Second_Delete_Warning_NO_Button= .t.
            script_play_local("end")
            END SELECT

            'Delete child records in Table Banking
            tbl=table.open("banking")
            'Perform a query to find Banking Persons
            query.filter = "Person = " + quote(name)
            qry_find = tbl.query_create()
            tbl.delete_range()
            tbl.close()

            MORE OF THE SAME TYPE DELETES HERE

            'Delete Parent record in Table Personal Info
            tbl = tbl.current()
            tbl.delete_record()
            topparent.resynch()
            'Get record count and load Control Panel if no records remain
            i = tbl.records_get()
            if i = 0
            parentform.close(.f.)
            varP_Control_Panel = :Form.view("Control Panel","","","Center","Top")
            end if

            My first warning (outside this code) is fine, the second is fine, the child deletes are fine. But when we get to the tbl.delete_record() here at the end, I get an "Argument is incorrect data type"

            The only thing I can see is that tbl.current has been closed, but nowhere in the code does that happen. And it works if topparent.delete_record() is used, but then I get the extra warning message. Grrr.

            And it is in the change mode, Tom. Checked that. ;)
            Richard

            Comment


              #7
              Richard -

              From the <tbl>.delete() Help page:

              Code:
              tbl = [COLOR="Red"]table[/COLOR].current()
              [COLOR="Red"]tbl.change_begin()[/COLOR]
              tbl.delete()
              [COLOR="Red"]tbl.change_end(.T.)[/COLOR]
              Yours appears to be:

              Code:
              'Delete Parent record in Table Personal Info
              tbl = [COLOR="Blue"]tbl[/COLOR].current()
              tbl.delete_record()
              topparent.resynch()
              'Get record count and load Control Panel if no records remain
              i = tbl.records_get()
              if i = 0
              parentform.close(.f.)
              varP_Control_Panel = :Form.view("Control Panel","","","Center","Top")
              end if
              Apart from the table pointer problem, I don't see where you place the table in change mode. Try making these modifications as appropriate and give it another try.

              - John O
              John Oesterle
              ToolBytes, LLC

              Comment


                #8
                Richard, I'll wager the table is not in change mode by the time the parent record is ready to be deleted. The most reliable approach is:

                a) check the mode of the table at the top of the script
                b) force user to commit or cancel any pending changes.
                c) then you know you're in VIEW mode.
                d) then delete the children
                e) then delete the parent, placing the tbl in change mode in your script

                Also, it would be smart to validate the query of the child table. Get the count of records in the query list. If it's zero then there are none to delete and your script can branch accordingly. As it stands it will try to delete records when there may be none in the query list. I don't know if that would throw an error or not. But it might.

                -- tom

                Comment


                  #9
                  Well, John was right, but other than the

                  tbl.change_end(.T.)

                  I had done that before and gotten an error that said it was already in the change mode, so I removed the statement.

                  Perhaps, though, Tom's last comment will prove to be the reason for it.

                  Thanks to you both. Hopefully, this darn epoc has now ended! :)
                  Richard

                  Comment

                  Working...
                  X