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

Creating Multiple Excel Worksheets from one export Script

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

  • #31
    Re: Creating Multiple Excel Worksheets from one export Script

    Hi Stan. Tried your last suggestion. The first client appears in the cvar box but nothing ever appears in the tbl.client box. I know there are more clients that fit the query filter but it is not getting to them. Just running a regular query using the same filter criteria, there should be 9 clients.

    Comment


    • #32
      Re: Creating Multiple Excel Worksheets from one export Script

      Stan, I just noticed if I put "cvar" in one box and then "A_tbl" in the next box down, as it steps through, when it gets to "A_tbl = table.open("New_Invoicing")", an error pops up stating "New_Invoicing" can't be opened because it's already being used by another process. I assume it's where we already opened it earlier in the script.

      Comment


      • #33
        Re: Creating Multiple Excel Worksheets from one export Script

        Not sure what happened but it's not doing that now. Now it runs through however with "A_tbl" entered in the box, no value appears as it runs through. For whatever reason, it's not opening another instance of the New_Invoicing table.

        Comment


        • #34
          Re: Creating Multiple Excel Worksheets from one export Script

          Now it runs through however with "A_tbl" entered in the box
          Not a_tbl, just tbl.client.

          If cvar acquires a value it must come from =tbl.client.

          Can you attach a sample of the table?
          There can be only one.

          Comment


          • #35
            Re: Creating Multiple Excel Worksheets from one export Script

            Haven't done that before..... how do I attach the table?

            Comment


            • #36
              Re: Creating Multiple Excel Worksheets from one export Script

              Create a zip of the table in Alpha.
              Start a post here, scroll down till you see Go Advanced at the lower right.
              Screen changes, scroll down till you see Manage Attachments, ......................
              There can be only one.

              Comment


              • #37
                Re: Creating Multiple Excel Worksheets from one export Script

                How do I attach the table? Just saw your answer.....

                Comment


                • #38
                  Re: Creating Multiple Excel Worksheets from one export Script

                  OK.... here is the table...... Will be gone until next Tuesday, but may be able to work from home this weekend. Thanks for everything.....
                  Attached Files

                  Comment


                  • #39
                    Re: Creating Multiple Excel Worksheets from one export Script

                    My bad.

                    1. We can't use batch_begin()..batch_end() because those don't allow the table to accessed by another pointer.
                    2. typo in the export portion of the script was querying the original table, not the second instance, thus the end of file was hit.

                    Code:
                    dim tbl as P
                    dim cvar as C
                    'open the New_Invoicing table to get client id numbers
                    tbl = table.open("New_Invoicing")
                    'put table in client order so we can skip over multiple instances and export only once per client
                    tbl.order("client")
                    'start at the first client id found
                    tbl.fetch_first()
                    WHILE .NOT. tbl.Fetch_EOF()
                    	'read theclient id of the current record and store that to the cvar variable
                    	cvar = alltrim(tbl.client) 'added to remove spaces in client id
                    	'open a second instance of the table for the exporting source
                    	a_tbl = table.open("New_Invoicing")
                    	'set options and query for the client id obtained above
                    	query.description = ""
                    	query.order = "CLIENT+DATE"
                    	query.filter = "CLIENT = "+quote(cvar)+" .AND. INVOICE_AMOUNT1-CHECK1-CHECK2-CHECK3-CHECK4>0"
                    	query.options = "I"
                    	a_tbl.query_create() ' not tbl.query_create()
                    	'the a_tbl pointer now only sees the records queried
                    	export.type = 4
                    	export.names = .T.
                    	export.file = "c:\temp\("+cvar+").xls"
                    	export.options = ""
                    	export.field_sep = ""
                    	export.record_sep = ""
                    	export.fields = 8
                    	export.field1 = "client"
                    	export.field2 = "date"
                    	export.field3 = "invoice_number1"
                    	export.field4 = "invoice_amount1"
                    	export.field5 = "date6"
                    	export.field6 = "invoice_number2"
                    	export.field7 = "invoice_amount2"
                    	export.field8 = "check5"
                    	a_tbl.export()
                    	'we've exported the records so now close the exporting source instance
                        a_tbl.close()
                        'in the original instance of the table,skip over any more records with the same client id 
                    	while tbl.client = cvar .and. .not. tbl.fetch_eof()
                    	tbl.fetch_Next()
                    	end while
                    	'we're now at the next unique client id, when we get back to the top of this while loop
                    	'the cvar = tbl.client will capture the client id and use that for the next export
                    	'etcetera
                    END WHILE
                    tbl.close()
                    Last edited by Stan Mathews; 01-30-2015, 11:22 AM.
                    There can be only one.

                    Comment


                    • #40
                      Re: Creating Multiple Excel Worksheets from one export Script

                      Thanks Stan. I had no idea that the 2 "batches" would lock the table so to speak. Thank you for all your hard work on this. I was definitely at a loss.

                      Comment


                      • #41
                        Re: Creating Multiple Excel Worksheets from one export Script

                        All Change and Enter operations in the specified table pointer (<TBL>) that occur between the <TBL>.BATCH_BEGIN()and its corresponding <TBL>.BATCH_END(), are optimized.

                        Alpha Five optimizes data entry operations by either opening the table exclusively or by preventing write access to the file by other users.
                        So it probably wouldn't have helped anyway. An export doesn't involve changes or enters.
                        There can be only one.

                        Comment


                        • #42
                          Re: Creating Multiple Excel Worksheets from one export Script

                          Stan,

                          I would never accuse you of Sniping. I would never claim that my code was the cleanest, or even very good. I just know that it works for us.

                          Tom

                          Comment


                          • #43
                            Re: Creating Multiple Excel Worksheets from one export Script

                            I just know that it works for us.
                            And that's what it's all about. Wanted to make sure you knew none of my comments/additions were critical.
                            There can be only one.

                            Comment


                            • #44
                              Re: Creating Multiple Excel Worksheets from one export Script

                              Stan. I just got back into the office today. Tried running the script and it worked flawlessly. Thank you so much for the insight, help and sharing your knowledge. This Saturday I will be coming into the office to upgrade to v11. I will be opening all scripts, forms and operations in design or edit mode and then saving them. Wish me luck....lol. Thanks again!
                              Scott

                              Comment


                              • #45
                                Re: Creating Multiple Excel Worksheets from one export Script

                                Originally posted by draxx2755 View Post
                                Stan. I just got back into the office today. Tried running the script and it worked flawlessly. Thank you so much for the insight, help and sharing your knowledge. This Saturday I will be coming into the office to upgrade to v11. I will be opening all scripts, forms and operations in design or edit mode and then saving them. Wish me luck....lol. Thanks again!
                                Scott
                                Try it with a backup copy first...
                                Robin

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

                                Comment

                                Working...
                                X