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 Last Years Sales

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

    #61
    Re: Copy Last Years Sales

    For those following along at home this can also be done with an append operation and improve the performance.

    Yes a table can append to itself.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


      #62
      Re: Copy Last Years Sales

      if year(tbl_a.yourdatefield) = curYr-2
      is this correct?
      thanks for reading

      gandhi

      version 11 3381 - 4096
      mysql backend
      http://www.alphawebprogramming.blogspot.com
      [email protected]
      Skype:[email protected]
      1 914 924 5171

      Comment


        #63
        Re: Copy Last Years Sales

        Originally posted by GGandhi View Post
        is this correct?
        Yes, NO, Yes, Errrr, No! I changed it to '2' because there were no 2014 records, only 2013. I changed the script above to '1'. Thanks for pointing this out.
        TYVM :) kenn

        Knowing what you can achieve will not become reality until you imagine and explore.

        Comment


          #64
          Re: Copy Last Years Sales

          Originally posted by Al Buchholz View Post
          For those following along at home this can also be done with an append operation and improve the performance.

          Yes a table can append to itself.
          How is this done? There is no way to select the fields. I seems to want to append the entire table. Even if there was a way to select the fields, it would need the ability to select a filter as well.
          TYVM :) kenn

          Knowing what you can achieve will not become reality until you imagine and explore.

          Comment


            #65
            Re: Copy Last Years Sales

            Originally posted by forskare View Post
            How is this done? There is no way to select the fields. I seems to want to append the entire table. Even if there was a way to select the fields, it would need the ability to select a filter as well.
            Yes the append auto fills the fields that match.

            You can delete the lines that are not needed.

            There is a select records option.

            Working up an example now.
            Al Buchholz
            Bookwood Systems, LTD
            Weekly QReportBuilder Webinars Thursday 1 pm CST

            Occam's Razor - KISS
            Normalize till it hurts - De-normalize till it works.
            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
            When we triage a problem it is much easier to read sample systems than to read a mind.
            "Make it as simple as possible, but not simpler."
            Albert Einstein

            http://www.iadn.com/images/media/iadn_member.png

            Comment


              #66
              Re: Function - How many reasons....

              tlc_3apps_set.zip

              unzip this set and add to your database.

              There is an operation for the set that appends only the fields you've shown in your code and has a select on it.

              The set has one table in it, the tlc-3apps table, and the set was used to ease the installation of this into an existing database.

              kenn1.JPG

              To remove the fields you don't want to append, highlight the fields you don't want to append and delete them from the append list.

              You can also delete the Estabdate field from the list

              The select records is shown and could/should be changed to be a dialog prior to running the operation. But I'm trying to get you rolling on the right track.

              An append operation is faster because it runs a C++ routine to do the work rather than xbasic.

              See notes from Ira about C++ vs xbasic
              Al Buchholz
              Bookwood Systems, LTD
              Weekly QReportBuilder Webinars Thursday 1 pm CST

              Occam's Razor - KISS
              Normalize till it hurts - De-normalize till it works.
              Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
              When we triage a problem it is much easier to read sample systems than to read a mind.
              "Make it as simple as possible, but not simpler."
              Albert Einstein

              http://www.iadn.com/images/media/iadn_member.png

              Comment


                #67
                Re: Copy Last Years Sales

                Ken,

                If you look for the line with "' Now import least year's sales back into the main table" in post #56,
                You'll find append code underneath it.

                I never considered appending data to/from the same table in a single append operation, but I'm guessing
                it shouldn't be too difficult to append fewer fields.
                Gregg
                https://paiza.io is a great site to test and share sql code

                Comment


                  #68
                  Re: Copy Last Years Sales

                  Originally posted by madtowng View Post
                  Ken,

                  If you look for the line with "' Now import least year's sales back into the main table" in post #56,
                  You'll find append code underneath it.

                  I never considered appending data to/from the same table in a single append operation, but I'm guessing
                  it shouldn't be too difficult to append fewer fields.
                  Gregg

                  Yes the append code is there but only seen if you scroll through it.

                  And the copy isn't needed to get the records initially.

                  Good point about the records might already be there and therefore duplicated. That option isn't handled in any of the solutions provided.

                  But the append would handle it if the option to append unique only is used. Of course you need to id what makes a record unique.

                  That's Kenn's job.
                  Al Buchholz
                  Bookwood Systems, LTD
                  Weekly QReportBuilder Webinars Thursday 1 pm CST

                  Occam's Razor - KISS
                  Normalize till it hurts - De-normalize till it works.
                  Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                  When we triage a problem it is much easier to read sample systems than to read a mind.
                  "Make it as simple as possible, but not simpler."
                  Albert Einstein

                  http://www.iadn.com/images/media/iadn_member.png

                  Comment


                    #69
                    Re: Copy Last Years Sales

                    Ok...a little reworking.
                    The code below now appends to/from the same table.
                    I added a bit to automatically use the last year in the table, as long as that year is less than the current year.

                    Special note to AL ... Thanks for the heads up of being able to append to the same table. That saves a lot of time once you figure out the filter :)

                    Code:
                    DIM Append as P
                    
                    a_tbl = table.open("tlc_3apps")
                    append.t_db = "tlc_3apps"
                    ON ERROR GOTO ERROR23032015164914265
                    
                    if tablemax("tlc_3apps","1=1","year(Estabdate)") >= year(date()) then
                    end
                    end if
                    yearcount = year(date()) - tablemax("tlc_3apps","1=1","year(Estabdate)")
                    
                    append.m_key = ""
                    append.t_key = ""
                    append.m_filter = ""
                    append.t_filter = "year(Estabdate) = year(date())-yearcount"
                    append.type = "All"
                    append.m_count = 10
                    append.m_field1 = "CUSTOMERID"
                    append.m_exp1 = "@TLC_3APPS->CUSTOMERID"
                    append.m_field2 = "SVCSITEID"
                    append.m_exp2 = "@TLC_3APPS->SVCSITEID"
                    append.m_field3 = "Service"
                    append.m_exp3 = "@TLC_3APPS->Service"
                    append.m_field4 = "Svc_Descrip"
                    append.m_exp4 = "@TLC_3APPS->Svc_Descrip"
                    append.m_field5 = "Svc_Zip"
                    append.m_exp5 = "@TLC_3APPS->Svc_Zip"
                    append.m_field6 = "Sale"
                    append.m_exp6 = "@TLC_3APPS->Sale"
                    append.m_field7 = "Exempt"
                    append.m_exp7 = "@TLC_3APPS->Exempt"
                    append.m_field8 = "Comborate"
                    append.m_exp8 = "@TLC_3APPS->Comborate"
                    append.m_field9 = "Discount"
                    append.m_exp9 = "@TLC_3APPS->Discount"
                    append.m_field10 = "Disc_Note"
                    append.m_exp10 = "@TLC_3APPS->Disc_Note"
                    append.t_count = 0
                    
                    a_tbl.append()
                    
                    
                    GOTO CONTINUE23032015164914265
                    ERROR23032015164914265:
                    ON ERROR GOTO 0
                    ui_msg_box("Error","Error running Append Operation"+crlf()+error_text_get())
                    END
                    CONTINUE23032015164914265:
                    a_tbl.close()
                    'If the Operation is run from within a Form or Browse, then refresh the window
                    if is_object(topparent.this) then
                    	if topparent.Class() = "form" .or. topparent.class() = "browse" then
                    		topparent.Refresh_layout()
                    	end if
                    end if
                    Gregg
                    https://paiza.io is a great site to test and share sql code

                    Comment


                      #70
                      Re: Copy Last Years Sales

                      Al,
                      That is way cool. It works great. How did you know to create a 1 table set (I wouldn't of had a clue) instead of using the table? What is significant about using the set vs the table. I see the way to gain access to the fields is to check the different field names radio 'o'.

                      Gregg,
                      Thanks for your code. You whip through that like a spoon through whipped cream. (Yum)

                      Al & Greg,

                      You guys have given me some new insights and something to play with for awhile.

                      Thanks sooooo much.
                      TYVM :) kenn

                      Knowing what you can achieve will not become reality until you imagine and explore.

                      Comment


                        #71
                        Re: Copy Last Years Sales

                        Originally posted by Al Buchholz View Post
                        The set has one table in it, the tlc-3apps table, and the set was used to ease the installation of this into an existing database.
                        The use of a single table set has nothing to do with the operation. You can build this operation on the table.

                        A single use set has some advantages that include sending objects to another database with out being confused about which file to send without sending the data.

                        I've also learned to use a utility of set that allows you to point to another table. Right Click the set, Utilities, Repair Set. It works through the set definition table by table and allows you to point to another table or keep what you have.

                        Originally posted by forskare View Post
                        Al,
                        That is way cool. It works great. How did you know to create a 1 table set (I wouldn't of had a clue) instead of using the table? What is significant about using the set vs the table.

                        I see the way to gain access to the fields is to check the different field names radio 'o'. (Please clarify - I'm confused about this.)
                        The single table set is a by-product of using a lot of passive linked tables that by their design rebuild the structure files and wipe out any objects in them. But the set is completely separate and is untouched.

                        I believe it was Selwyn who prompted their use.

                        To repeat (again), the single set is not needed for the append to work. But does make it easier to integrate into a database.

                        I would do as Gregg has shown and use the code to build a function along with some other options to avoid duplication of data.
                        Al Buchholz
                        Bookwood Systems, LTD
                        Weekly QReportBuilder Webinars Thursday 1 pm CST

                        Occam's Razor - KISS
                        Normalize till it hurts - De-normalize till it works.
                        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                        When we triage a problem it is much easier to read sample systems than to read a mind.
                        "Make it as simple as possible, but not simpler."
                        Albert Einstein

                        http://www.iadn.com/images/media/iadn_member.png

                        Comment


                          #72
                          Re: Copy Last Years Sales

                          Hi Al,

                          <quote>I see the way to gain access to the fields is to check the different field names radio 'o'. (Please clarify - I'm confused about this.)</quote>

                          When creating the operation, there is the option, fields have or do not have the same names. If the same name option is selected, it bypasses the field matching step. In order to select certain fields, as opposed to all fields, the fields have different names option must be selected.

                          After giving this process some thought, I decided to try a three operation process. First, I duplicated the table and then removed all the data from the new table. Then I created three (3) operations.

                          1. Append all records from Table A to the new table, Table B.
                          2. delete all records in Table A
                          3. Append/copy the data in selected fields from Table B to Table A, using the ask var to select the records for the correct year.

                          I created 3 buttons on a form, one for each operation. This works great. Now, I need to try putting all 3 operations on one button push. I'm not sure if this will work because the operation is complete a message box pops up which requires user action. If it does work that way, that's OK. The advantage is still using one button instead of 3.
                          Last edited by forskare; 03-24-2015, 01:02 AM.
                          TYVM :) kenn

                          Knowing what you can achieve will not become reality until you imagine and explore.

                          Comment


                            #73
                            Re: Copy Last Years Sales

                            Originally posted by forskare View Post

                            <quote>I see the way to gain access to the fields is to check the different field names radio 'o'. (Please clarify - I'm confused about this.)</quote>

                            When creating the operation, there is the option, fields have or do not have the same names. If the same name option is selected, it bypasses the field matching step. In order to select certain fields, as opposed to all fields, the fields have different names option must be selected.
                            Reading between the lines, you are using the genie to create the operation. From the images I have shown, you can see I 'm not using the genie.
                            Originally posted by forskare View Post
                            After giving this process some thought, I decided to try a three operation process. First, I duplicated the table and then removed all the data from the new table. Then I created three (3) operations.

                            1. Append all records from Table A to the new table, Table B.
                            2. delete all records in Table A
                            3. Append/copy the data in selected fields from Table B to Table A, using the ask var to select the records for the correct year.

                            I created 3 buttons on a form, one for each operation. This works great. Now, I need to try putting all 3 operations on one button push. I'm not sure if this will work because the operation is complete a message box pops up which requires user action. If it does work that way, that's OK. The advantage is still using one button instead of 3.
                            Explain in user terms what you are trying to accomplish.

                            Looks to me like you want the new records and not the old records that are there originally.
                            Al Buchholz
                            Bookwood Systems, LTD
                            Weekly QReportBuilder Webinars Thursday 1 pm CST

                            Occam's Razor - KISS
                            Normalize till it hurts - De-normalize till it works.
                            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                            When we triage a problem it is much easier to read sample systems than to read a mind.
                            "Make it as simple as possible, but not simpler."
                            Albert Einstein

                            http://www.iadn.com/images/media/iadn_member.png

                            Comment


                              #74
                              Re: Copy Last Years Sales

                              The table is for keeping track of customer services/sales. Each year, the customer has the option of signing up for the previous years services. Each of the 5,000 customers will purchase anywhere from 1 to 10 services. Obviously some data/fields are repetitive every year and some are not. The question: what is the best way to avoid repetitive data entry, saving a huge amount of staff time? Based on the above code, I am able to append the data from various fields to the same table and using your append operation, the processing time is cut from about 3.5 minutes to less than 30 seconds.

                              As the years go by, the amount of screen space it takes to display the customer's services increases and there is no need to show the past years services other than to view them on an as needed basis. Using the append to the same table every year will soon create this problem; too many records to view when not needed. The best option that I came up with is to append all records (every field) to a like table which will be basically, used as an archive table. Now the records in the Sales table, must be purged and then the append from the archived table to the Sales table will create the new records needed for the new year. This is a 3 step process.

                              As I was typing this, the thought occurred, instead of purging all records and then appending, it would be easier to simply remove the data from selected fields and change the Estabdate field value to reflect the new year. An arbitrary date could be used (say 1/1/15 for this year) or the Date() function could be used. The problem using the date function becomes, the year is the process is run. If in 2014, +1 will need to be included. If in 2015, then the +1 is not needed. Thus, an 'ask var' can be used to ask what year the new records are for.

                              Conclusion: I will work at purging the data from selected fields and changing the Estabdate field to reflect the new year. That will eliminate one part of the operation and make the overall operation smoother and quicker.

                              Hopefully, I've explained this sufficiently.
                              TYVM :) kenn

                              Knowing what you can achieve will not become reality until you imagine and explore.

                              Comment


                                #75
                                Re: Function - How many reasons....

                                That sounds like an append to the archive and then an update operation to change the date and to blank/zero out some fields.

                                easy-peasy

                                It's always good to write out the thoughts. It usually forces me to think clearly.

                                It's also the magic of the messageboard.....
                                Al Buchholz
                                Bookwood Systems, LTD
                                Weekly QReportBuilder Webinars Thursday 1 pm CST

                                Occam's Razor - KISS
                                Normalize till it hurts - De-normalize till it works.
                                Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                                When we triage a problem it is much easier to read sample systems than to read a mind.
                                "Make it as simple as possible, but not simpler."
                                Albert Einstein

                                http://www.iadn.com/images/media/iadn_member.png

                                Comment

                                Working...
                                X