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

Copy previous record from two tables

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

    Copy previous record from two tables

    Hello,

    Im trying to create an operation that will copy the previously entered record of two tables. I know how to accomplish this when Im copying a record in just one table, but two tables has me stumped.

    I have a form based on two tables that are joined as a set, and I want to add a button that when pressed will copy the last record from table a, and table b. Then I want to place this copied record into edit mode to change to a new students ID#. The ID# needs to update the parent and child record.

    Is there way to accomplish using the genies? Im barely learning xbasic so this is a bit overwhelming to write. Anything will help, Thanks.

    -Ivan

    #2
    Re: Copy previous record from two tables

    Are you saying you want to make one record in a table out of two records in other tables, combining them? The destination has the same fields as both the other tables?

    Whether you use action scripting or xbasic the process will involve copying the record from either of the source tables to the destination table and writing the desired fields from the other source table to the new destination table record.

    Not the sort of thing the genies can handle.
    There can be only one.

    Comment


      #3
      Re: Copy previous record from two tables

      its more like duplicating the record (in the respective tables), then placing the duplicated record into edit mode to change the student ID. This is all happening in a form by the way.

      I was afraid you would say the genies are unable to accomplish this.

      Do you know of any great learning tools for learning xbasic?

      Comment


        #4
        Re: Copy previous record from two tables

        If you have two table records from which you want to make one final record it is not duplicating (to Alpha). You have to create a record in the destination table and fill in the fields form both of the source records. Alternatively, copy the record from one table and fill in the fields from the other.

        I'll try to work up a sample.
        Attached Files
        Last edited by Stan Mathews; 08-13-2014, 05:19 PM.
        There can be only one.

        Comment


          #5
          Re: Copy previous record from two tables

          See my attached example

          If you look at the form, and the table set up, Im not trying to combine records. I'm trying to copy a previous record and replace fields manually. See the button Action Scripting so you can kind of see what im trying to accomplish here. The action scripting I placed there is not doing what I want it to do.
          Attached Files

          Comment


            #6
            Re: Copy previous record from two tables

            Hi Ivan,
            I think the problem in trying to copy the record in the browse and then pasting it into the new parent record browse is the link is also being copied from the source and is not linking to the new record. Perhaps a lookup field rule in the notes table would be a better way to use a previous record after you have duplicated the parent record.
            Robin

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

            Comment


              #7
              Re: Copy previous record from two tables

              See if this does what you want.
              Attached Files
              There can be only one.

              Comment


                #8
                Re: Copy previous record from two tables

                PERFECT!! :) That did do it stan, that's exactly what I wanted to do. Now I need to research what you did in xbasic so I can understand whats going on and how to do it on my own. I have other tables where I need to perform this type of operation so I need to learn thing quick.

                Thank you again stan.

                Comment


                  #9
                  Re: Copy previous record from two tables

                  Commented version of the script.

                  Code:
                  'save the current record on the form
                  topparent.commit()
                  'establish pointer to parent table (1)
                  src1 = table.current(1)
                  'establish pointer to child table(2)
                  src2 = table.current(2)
                  'save current record data from both tables to variables
                  record_data1 = src1.record_data_get()
                  record_data2 = src2.record_data_get()
                  'start a new parent record
                  src1.enter_begin()
                  'write previous parent record data to parent table
                  src1.record_data_set(record_data1)
                  src1.enter_end(.T.)
                  'get the linking field value from the new record as created by auto-increment
                  new_id = src1.orientation_id
                  'start a new child record
                  src2.enter_begin()
                  'write previous child record data to parent table
                  src2.record_data_set(record_data2)
                  'set/overwrite the linking field value to the new parent record linking value
                  src2.Orientation_Id_Fk = new_id
                  src2.enter_end(.T.)
                  'resynch the form to the set
                  topparent.resynch()
                  'refresh the display of the form
                  topparent.repaint()
                  There can be only one.

                  Comment


                    #10
                    Re: Copy previous record from two tables

                    So just to clarify, to establish a pointer like in "src1=table.current(1)", this points to the first table in the set which is the parent, right?

                    With that logic if this particular set had 5 tables, and I only wanted to copy a record in the third table in the set, the function would be "src3 = table.current(3)" right? Where "src3" is just the name of the variable. Is my thinking on the right path?

                    Comment


                      #11
                      Re: Copy previous record from two tables

                      Correct. The # supplied refers to the vertical position of the table in the set when viewed in the set editor. No adjustment is made for relative "importance" of the linked table. IOW, count straight down ignoring whether the linked table is linked to the parent or linked to another child table.
                      There can be only one.

                      Comment


                        #12
                        Re: Copy previous record from two tables

                        Is it possible to cut this xbasic code in half? In other words, create an operation that copies src2 record, and then create a different button that will paste the record once you've navigated to a record of your choosing?

                        I already tried to break this up but I guess i'm not doing it correctly.

                        My goal is to be able to navigate to a parent record and edit roughly 3 fields, then enter a note in the child table in regards to the edited fields, copy said note from the child table. Then navigate to a different parent record, manually edit roughly three fields again, and paste the previous record note to this record (all while updating the linking field ID's ofcourse). I tried to establish variables within the form to store the info, but the variable keeps losing its definition???

                        Comment


                          #13
                          Re: Copy previous record from two tables

                          Well, I got it to copy and paste, with two separate buttons. But this only works if I stay on the same parent record. Once I navigate and try to paste, it does nothing. Also the ID's are not updating

                          Comment


                            #14
                            Re: Copy previous record from two tables

                            Sorry, your description lost me.
                            There can be only one.

                            Comment


                              #15
                              Re: Copy previous record from two tables

                              This part of the script captures the values in the current record.

                              Code:
                              'establish pointer to parent table (1)
                              src1 = table.current(1)
                              'establish pointer to child table(2)
                              src2 = table.current(2)
                              'save current record data from both tables to variables
                              record_data1 = src1.record_data_get()
                              record_data2 = src2.record_data_get()
                              If you are splitting the script into two parts, the second script will not know anything about what happened before unless you make the variables available to it.

                              Code:
                              dim shared src1 as P
                              dim shared src2 as P
                              dim shared record_data1 as B
                              dim shared record_data2 as B
                              'establish pointer to parent table (1)
                              src1 = table.current(1)
                              'establish pointer to child table(2)
                              src2 = table.current(2)
                              'save current record data from both tables to variables
                              record_data1 = src1.record_data_get()
                              record_data2 = src2.record_data_get()
                              Now the first of the second script should establish the connection to the same variables.

                              Code:
                              dim shared src1 as P
                              dim shared src2 as P
                              dim shared record_data1 as B
                              dim shared record_data2 as B
                              'rest of second script goes here
                              There can be only one.

                              Comment

                              Working...
                              X