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

Back to duplicating a record with child tables.

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

    #16
    Re: Back to duplicating a record with child tables.

    Originally posted by Ronald Anusiewicz View Post
    It sounds like there is a timing issue where the new form is opening before the first form closes. That's why the second form has a number at the end.
    The xbasic_wait _for_idle is an attempt to have the first form close before the second form opens.

    That said, I always try to avoid explicit code just for this reason
    I do not think it is a timing issue but the fact that the original form does not actually close until the script that was run from it finishes and exits. You can put a WAIT_UNTIL() and have it time out for 1 or 2 seconds and it will still open the new form with a number behind its name.

    I had started using explicit's in places as I had some issues with non-explicit statements not working well in a multi-user environment. I went ahead and took them out for this right now but I am still highly curious as to why you have to close and reopen the form to get the one to many fields to display the values in the table.

    Update:

    Changing the code
    Code:
    Parentform.Close(.f.)
    xbasic_wait_for_idle()
    
    dim Frm as P
    Frm = Form.load("work_orders")
    Frm.Index_Set("inv_id")
    Frm.find(newinvoice)
    Frm.show()
    Frm.activate()
    
    this.enable()	'enable button on way out
    To:

    Code:
    topparent.fetch_last()
    parentform.Repaint()
    Seems to work. Need to test more to make sure but it looks like it does the trick.

    Using it no longer renames the form as it never closes and the parentform.repaint() populates the one to many fields on the form.

    Update to Update:

    This turned out to not be reliable. Need to investigate more into it.
    Last edited by preston2; 08-18-2016, 05:50 PM.

    Comment


      #17
      Re: Back to duplicating a record with child tables.

      Maybe try it as


      codeTxt = <<%code%
      dim Frm as P
      Frm = Form.load("work_orders")
      Frm.Index_Set("inv_id")
      Frm.find(newinvoice)
      Frm.show()
      Frm.activate()
      %code%
      this.enable() 'enable button on way out
      parentform.Close()
      on_xbasic_idle(codeTxt,"R")
      Last edited by Stan Mathews; 08-18-2016, 03:50 PM. Reason: moved this.enable()
      There can be only one.

      Comment


        #18
        Re: Back to duplicating a record with child tables.

        Sort of works Stan.

        I had to comment out the Frm.find(newinvoice) as it would not pick up that variable. I could make it global and then it would.

        It totally closes the form, delays a bit and then reopens it.
        Problem is it sets some weird query that can only be cleared by clicking a "Show All" button on the form or closing it down and restarting it.

        Comment


          #19
          Re: Back to duplicating a record with child tables.

          This seems to work.
          It does totally close the form and then reopens it after about a second but I may be able to live with that.

          I also does not cause the crazy query issue I mentioned above.

          Code:
          codeTxt = <<%code% 
          script_play("open_estimates") 'A script I use elsewhere to open the form.
          %code% 
          parentform.Close() 
          on_xbasic_idle(codeTxt,"R")

          Comment


            #20
            Re: Back to duplicating a record with child tables.

            The following can be used to refresh an embedded browse, based on a child records, after additional child records are added outside of the form.

            Pwin.Browse_device.resynch()

            Where Pwin is a pointer to the window with the form. You can use the Object explorer to get the actual Object Name or use;

            topparent:Browse1.resynch()

            Where browse1 is the name of the browse that needs to be updated.

            Another option for forcing multiple browses to resync is moving to a different parent record and then moving back to the record of interest. Something like.

            REcNum = :topparent.recno_goto(xx)

            Comment


              #21
              Re: Back to duplicating a record with child tables.

              The only thing with duplicating a record and then showing it on the existing form is that if the user looks away for a second he's liable to think nothing happened. Why not pop up a form to show the new record in a modified form then allow the user to make a few edits or confirm the record before returning him to the main form?
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #22
                Re: Back to duplicating a record with child tables.

                Robin, I use a ui_msg to tell them they are about to duplicate and then another one that tells them is is done. If they look away, they will be staring at the last message when they look back.

                Paul, .resync() does not work on the one to many.

                Comment


                  #23
                  Re: Back to duplicating a record with child tables.

                  Preston,

                  The problems you are having are directly related to the down side of manipulating data using xbasic and trying to refresh forms using form coding. I hope that makes sense. When you look at my original code, you will see lines that don't appear to be needed. Well, those lines of code were added to make the form behave the way I wanted while using xbasic to change the data. Truthfully, this can be a nightmare. .Refresh(), .resycn() or .repaint() don't always work. That's why I ended up closing the form and reopening the form. When I opened the new form, I had to make sure I navigated to the new entry. That's why I used the form load, etc... Tom Cone and I have talked this over and we both believe it's directly related to timing issues.

                  I don't know the real answer but the code I provided is working for me in my particular situation.
                  Alpha 5 Version 11
                  AA Build 2999, Build 4269, Current Build
                  DBF's and MySql
                  Desktop, Web on the Desktop and WEB

                  Ron Anusiewicz

                  Comment


                    #24
                    Re: Back to duplicating a record with child tables.

                    Ron,

                    I ended up going with code based on yours but with simplified version of Stan's suggestion for using on_xbasic_idle(codeTxt,"R") instead of the quick re-opening which adds the number after the form name. My form already run topparent.fetch_last() when it starts up and take them to the last record which would be the duplicated one. That is unless two people actually duplicate a record at the same time.

                    On my form that is all one to one (parent and five children) I used a modified version of your code all the way as it does not matter if it gets reopened with a number after the form name.

                    But on the form with the one to many, it does matter because they can open other forms and preform a query back to that form. If it has been opened during a duplication with a number after the name and then they query to it from another form, it opens another copy of the form without the number after the name and then you end up with multiple copies of the form opened.

                    What really get me is this should be simple and part of Alpha's built in functions or methods. But it is like they never realized that most forms are built off a set and when duplicating it would also need to duplicate records from the child tables.

                    Comment


                      #25
                      Re: Back to duplicating a record with child tables.

                      Well, it would be nice if duplicating a record would duplicate the children, but it doesn't. I don't know if you allow the deletion of a record, but if you don't use referential Integrity (and it's recommended not to), then you will need to delete each child using xbasic. The code I use is similar to the code I use to add a child.
                      Alpha 5 Version 11
                      AA Build 2999, Build 4269, Current Build
                      DBF's and MySql
                      Desktop, Web on the Desktop and WEB

                      Ron Anusiewicz

                      Comment

                      Working...
                      X