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

duplicate suddenly not working

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

    duplicate suddenly not working

    this code based on the great Xbasic for everyone by Dr Peter has suddenly stopped working (it worked up until about a month ago - I dont need to use it that often)

    Code:
    dim hdr as p
    dim items as p
    dim old_parent as b
    dim count_items as n
    dim i as n
    hdr=table.current(1)
    items=table.current(2)
    count_items = count(purchase_items2->order_no,grp->purchase_header2)
    if count_items>0 then
    dim records[count_items] as b
    i=0
    items.fetch_first()
    while i<count_items
    i=i+1
    records[i]=items.record_data_get()
    items.fetch_next()
    end while
    end if 'count_items>0
    old_parent=hdr.record_data_get()
    hdr.enter_begin()
    ' note, in this table the inv_no is
    ' an autoincrement field
    ' a new inv_no is assigned by the field rule,
    ' which overrides
    ' the Xbasic record_data_set()
    hdr.record_data_set(old_parent)
    hdr.order_date=date()
    hdr.del_date=date()
    hdr.enter_end(.t.)
    if count_items>0 then
    for i=1 to count_items
    items.enter_begin(.t.)
    items.record_data_set(records[i])
    items.order_no =hdr.order_no
    items.enter_end(.t.)
    next
    end if ' count_items>0
    parent.resynch()
    end
    It now seems to copy the child records to the original header, not the newly entered header record. Anyone else confirm? I have tried it on two different databases with same effect.

    #2
    Re: duplicate suddenly not working

    This would be easier for us to check if you supplied a working model with instructions for us to follow to find the event which triggers the code.

    Later...

    Is the link field in the parent table INV_NO or ORDER_NO ? Your script's comments suggest that INV_NO is autoinc ... is it the link field? Saying this differently: Is your script pulling the wrong field from the parent table when updating the ORDER_NO field in each new child table record?
    Last edited by Tom Cone Jr; 06-01-2007, 08:48 AM.

    Comment


      #3
      Re: duplicate suddenly not working

      Hi Tom, thanks for looking.

      This code is an exact copy of Dr Peters copying records from a set.

      As you can probably tell the set is Purchase header -1:M - purchase items, linked on the order no field in both. The order no field in purchase header is auto inc. Basically I have used Peter's code and addapted to my field names, and added the date lines to change the copied header date to the current date, and that is it.

      This was re-designed in version 6 and has been used in version 7 and version 8 successfully until today, I don't understand!!

      attached is a small test database, run the rooms form to see the duplicate button.

      Comment


        #4
        Re: duplicate suddenly not working

        Ok, what confused me is the comment in your script referencing a different autoinc field...

        I'll take a look.

        -- tom

        Comment


          #5
          Re: duplicate suddenly not working

          Lance,

          In your example you made the wrong field autoinc. I made the link field in the parent table of your set autoinc assuming that's what you intended.

          I think you should report this as a bug. The record pointer in the parent table is not being moved after the new parent table record is entered. This should happen automatically, but it's not. Suggest you attach the example database with your bug report, but only after you fix the autoinc field problem mentioned previously.

          If you want to fix the script here's an easy work around:

          Code:
          'Date Created: 01-Jun-2007 03:12:57 PM
          'Last Updated: 01-Jun-2007 11:23:58 AM
          'Created By  : Lance
          'Updated By  : Tom
          dim hdr as p
          dim items as p
          dim old_parent as b
          dim count_items as n
          dim i as n
          hdr=table.current(1)
          items=table.current(2)
          count_items = count(room_areas->room_no,grp->rooms)
          
          if count_items>0 then
          dim records[count_items] as b
          i=0
          items.fetch_first()
          while i<count_items
          i=i+1
          records[i]=items.record_data_get()
          items.fetch_next()
          end while
          end if 'count_items>0
          old_parent=hdr.record_data_get()
          hdr.enter_begin()
          ' note, in this table the [COLOR="Red"]room[/COLOR]_no is
          ' an autoincrement field
          ' a new [COLOR="Red"]room[/COLOR]_no is assigned by the field rule,
          ' which overrides
          ' the Xbasic record_data_set()
          hdr.record_data_set(old_parent)
          hdr.enter_end(.t.)
          [COLOR="Red"]parentform.resynch()   'force record pointer in parent table to refresh
          ui_yield()  'force script to wait for user interface to catch up[/COLOR]
          
          if count_items>0 then
          'for i=1 to count_items
          for j=1 to count_items   'use j instead of re-using i
          items.enter_begin(.t.)
          items.record_data_set(records[j])
          items.room_no =hdr.room_no
          items.enter_end(.t.)
          next
          end if ' count_items>0
          parent.resynch()
          end

          Comment


            #6
            Re: duplicate suddenly not working

            Thanks for that Stan, I will report the bug.

            In my example it is the area that needs to be the autoinc, not the link field, but the principle is the same.

            Comment


              #7
              Re: duplicate suddenly not working

              Originally posted by Lance Gurd View Post
              Thanks for that Stan, I will report the bug.

              In my example it is the area that needs to be the autoinc, not the link field, but the principle is the same.
              You're welcome, I think, for whatever contibution you think I made. Tom deserves at least some of the credit.
              There can be only one.

              Comment


                #8
                Re: duplicate suddenly not working

                No. In your example if you don't increment the room number, the room number entered into the new header table will match the original record's room number. You wind up with parent table records in your set that have duplicate link field values which is never recommended. Remember, in your form's set, the link field is room_no, not "area".

                Comment


                  #9
                  Re: duplicate suddenly not working

                  Sorry, I did mean to thank Tom, and was talking to a customer named Stan at the time.

                  Comment


                    #10
                    Re: duplicate suddenly not working

                    Trying to figure this out and see if it can work for what I need.

                    I have form which is built off a set.


                    The reason for the set is so I do not have 816+ fields in one table.

                    Looking at the examples here, since my set is all "One to One" would I need something like " count_items = count(matrix->matrix_id,grp->matrix) " ?

                    Linking field is Matrix_ID

                    Confused as hell.

                    Alpha version 11.

                    Comment


                      #11
                      Re: duplicate suddenly not working

                      see if it can work for what I need.
                      And what would that be? Are you trying to get a record count of the matrix table?
                      There can be only one.

                      Comment


                        #12
                        Re: duplicate suddenly not working

                        Stan, I originally posted this thread http://www.alphasoftware.com/alphafo...-child-records
                        And you refered me to this tread.

                        What I need to do is duplicate a record and all associated child records of the set to create a new record with all the same data as the first record in all the tables of the set save one unique field "Matrix_Name" and of course the Matrix_ID field which is auto-increment.

                        Comment


                          #13
                          Re: duplicate suddenly not working

                          The count_utems in that script is used to loop through the child records associated with the current parent. For a one-to-one set count_items is always 1.
                          There can be only one.

                          Comment

                          Working...
                          X