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

Append current record

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

  • Append current record

    When I enter a new record, then save it, I would like to append it to another table. I only want the one record I'm working on of course. I've tried filtering the append operation with

    RECNO() = CURRENT(RECNO() )

    That only appends the first record every time. I've tried adding a logical field called "posted" to the form which has a default of .F. when the record is started and after the append I set it to .T. and filter the append to only those records where "posted" is false. I can't even enter a second record.

    What's a good way to only deal with the current record?

    Thanks
    Bill Belanger

  • #2
    Re: Append current record

    Originally posted by [email protected] View Post
    When I enter a new record, then save it, I would like to append it to another table. I only want the one record I'm working on of course. I've tried filtering the append operation with

    RECNO() = CURRENT(RECNO() )

    That only appends the first record every time. I've tried adding a logical field called "posted" to the form which has a default of .F. when the record is started and after the append I set it to .T. and filter the append to only those records where "posted" is false. I can't even enter a second record.

    What's a good way to only deal with the current record?

    Thanks
    Bill Belanger
    Code:
    append.run("append_operation_name","recno() = " + table.current().recno() + ")"
    this will give you a filter that looks like this:

    recno() = 34


    assuming that the recno of the current record is 34.

    Comment


    • #3
      Re: Append current record

      Thanks Selwyn, that gives me an error of "missing right parenthesis" but I'm not sure where?

      Any idea why RECNO() = CURRENT(RECNO() ) would only append the first record every time?

      Bill Belanger

      Comment


      • #4
        Re: Append current record

        Looks like it should be

        Code:
        append.run("append_operation_name","recno() = " + table.current().recno() )
        There can be only one.

        Comment


        • #5
          Re: Append current record

          When I enter a new record, then save it, I would like to append it to another table.
          The most recently entered record might not be the current record.
          Depends on where you are entering from, what base filter/order is used.. what index, what query..
          Last edited by G Gabriel; 05-21-2008, 01:04 AM.

          Comment


          • #6
            Re: Append current record

            Thanks Gabriel.
            I don't have anything specified on the form as far as filters or indexes at all, so I assumed the record I am on would be the current record. Obviously something is making the first record I enter the current one as long as I keep entering records.

            Stan, your code works great! I even figured out how to add the .T. argument to get it to run silently.
            Thanks again everyone

            Bill Belanger

            Comment


            • #7
              Re: Append current record

              To make sure you are appending the most recently added record, instead of using current record in the filter, rather use the highest recno.

              Something like:
              append.run("append_operation_name","recno() = " + tablemax("table",recno()) )

              Comment


              • #8
                Re: Append current record

                Bill, if you are interested in an alternative, here's an idea. Consider not using an operation for this sort of thing. Instead, a simple script is used to save the current record and then enter it into the second table. To me operations seem best suited to processing batches of records. For single record transactions I prefer a rifle to a cannon, so to speak.

                Comment


                • #9
                  Re: Append current record

                  As in this twin thread.
                  Only issue is to make sure you are appending the "current" record.

                  Comment


                  • #10
                    Re: Append current record

                    Thanks Tom and Gabriel. Yes, of course the script idea is better. So far it looks like I actually have to have a form open in the other table in order to do that. Even then I get

                    Script:a5_form_duplicate_rec line:50
                    Record number is past end of table

                    I suppose I could use the copy_record_to but I prefer to use action scripting if I can. Still, all these action scripts refer to "the current record" and it seems I've been duped by assuming the record I'm looking at is the current record.

                    Bill Belanger

                    Comment


                    • #11
                      Re: Append current record

                      So far it looks like I actually have to have a form open in the other table in order to do that.
                      You don't.
                      Not sure how you arived at that conclusion?
                      I suppose I could use the copy_record_to but I prefer to use action scripting if I can. Still, all these action scripts refer to "the current record" and it seems I've been duped by assuming the record I'm looking at is the current record.
                      Here is a simple script you could put on your OnSave.
                      Code:
                      t=table.current()
                      t.query_create("t",".t.",recno())
                      t.fetch_last()
                      t1=table.open("other_table")
                      t1.enter_begin()
                      t1.field1=t.field1
                      t1.field2=t.field2
                      t1.enter_end(.t.)
                      t1.close()

                      Comment


                      • #12
                        Re: Append current record

                        Gabriel,
                        I was trying to duplicate the record in another "form", because that's the way action scripting does it. I can see by your xbasic script that the form wouldn't need to be open because you're opening the table. There is no action script for "open table" that I can find.

                        Bill

                        Comment


                        • #13
                          Re: Append current record

                          No offense intended to Gabe's script but if the form is already on the current record, why do a query on the current table to get the record mapping that needs to be copied?

                          Code:
                           
                          dim hdr as p = table.current()
                          dim tbl as p
                          dim commit_flag as L = .f.
                          on error goto INUSE
                          tbl = table.open("your_table_name")
                          tbl.enter_begin()
                            on error goto 0
                            [COLOR=navy]'if the table is not in use then the record enter can proceed[/COLOR]
                            commit_flag = .t.
                            tbl.field1 = hdr.field1
                            tbl.field2 = hdr.field2
                            'etc
                          tbl.enter_end(commit_flag)
                          CLOSEIT:
                          tbl.close()
                          end 
                          INUSE:
                          [COLOR=navy]'this will get the table closed if the error trap was triggered[/COLOR]
                          if commit_flag = .f.
                            [COLOR="Navy"]'table.open() triggered the error[/COLOR]
                            RESUME CLOSEIT
                          else
                            [COLOR="navy"]'the enter_begin() caused an error[/COLOR]
                            commit_flag = .f.
                            RESUME NEXT
                          end if
                          Robin

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

                          Comment


                          • #14
                            Re: Append current record

                            xbasic is superior to AS and not hard once you get the hang of it.
                            I don't believe but I can't swear to it that there is AS to open table.

                            Comment


                            • #15
                              Re: Append current record

                              No offense intended to Gabe's script but if the form is already on the current record, why do a query on the current table to get the record mapping that needs to be copied?
                              That's just it.. Bill said repeatedly that the first record is the one being appended, not the "current" one.
                              Originally posted by [email protected] View Post
                              Still, all these action scripts refer to "the current record" and it seems I've been duped by assuming the record I'm looking at is the current record.

                              Bill Belanger

                              Comment

                              Working...
                              X