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

Report.saveas("Dr_Report","rtf")

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

  • Report.saveas("Dr_Report","rtf")

    I am trying to use XBaasic to step through a filtered table and save each record as a separate PDF file, each with a different filename.

    Each record contains data for 1 report ie the Detail section of the report layout is only one record long.

    The code to open the table & step through the selected records is working ok but how can i code the actual report save??

    I am trying to use
    :Report.saveas("Dr_Report","rtf") where Dr_Report is the name of the layout.

    This results in ALL selected records being printed to 1 PDF...

    I think that i need to use a different filter_expression but if i set it to the current record i loose the original query on the table & only 1 record prints/saves.

    Any ideas???

  • #2
    Re: Report.saveas("Dr_Report","rtf")

    to step through a filtered table
    How is the table filtered? What is the identifier field for the records? What name do you want to save the report as ( a field's contents? )?

    For a form based on a single table where you have filtered/queried the form the general outline of the code would be (to save in the c:\temp directory)

    tbl = table.current()
    tbl.fetch_first()
    while .not. tbl.fetch_eof()
    :Report.saveas("Dr_Report","rtf","id = "+quote(alltrim(tbl.id)),"","c:\temp\\"+alltrim(tbl.name)+".rtf")
    tbl.fetch_next()
    end while
    Last edited by Stan Mathews; 09-29-2009, 12:36 PM.
    There can be only one.

    Comment


    • #3
      Re: Report.saveas("Dr_Report","rtf")

      Thanks Stan

      Here is my actual code:
      ====================================================
      dim tbl As P
      dim ReportPath As C
      dim FileName As C

      tbl = table.current()
      ReportPath = a5.Get_Path() + "\DrFolders\\"
      tbl.fetch_first()
      while .not. tbl.fetch_eof()
      FileName = alltrim(tbl.Firstname) + "_" + alltrim(tbl.lastname) + "(" + alltrim(str(tbl.SID2,9,0)) + ").pdf"
      :Report.saveas("DrReport1stpgV4","pdf","SID2 = " + alltrim(str(tbl.Sid2,9,0)),"",ReportPath + FileName)
      tbl.fetch_next()
      end while

      =======================================================

      This code is triggered by a button on a form that has been filtered to display 3 records.

      When i execute the code A5 seems to get caught in a loop and prints the 1st record over and over... it never seems to get to the next record (? fetch_next not working ??)

      Comment


      • #4
        Re: Report.saveas("Dr_Report","rtf")

        Form/report based on a table or set?

        This code is triggered by a button on a form that has been filtered to display 3 records.
        Three records in a browse or able to navigate three parent records?
        There can be only one.

        Comment


        • #5
          Re: Report.saveas("Dr_Report","rtf")

          form is based on a set...
          The filter selects 3 parent records. They are displayed in a browse on the form and navigating displays each of the three records in thge form at the same time showing the current record in the browse...

          Comment


          • #6
            Re: Report.saveas("Dr_Report","rtf")

            I'm going to have to see a sample database. I've never seen anything set up that way.
            There can be only one.

            Comment


            • #7
              Re: Report.saveas("Dr_Report","rtf")

              I will see if i can simulate the database... i can't send the actual tables because there is a lot of proprietary and personal Dr & patient information.

              Maybe it would help if i described what i am doing in a bit more detail:

              I have a set with 5 tables:
              SampleInfo --> H6_Sc(1:1) --> InterpMemos(1:1)
              --> Project(1:1) --> Client(1:1)
              --> InterpH2008(1:1)

              ... as shown all tables in the set are 1:1
              Each record contains all of the information necessary for a report i.e. there is only 1 record in the detail section of the report.

              I display the information in a form & allow the user to Query a range of records.

              I have a button on the form that, when pushed, will step through the Queried records & save the report as a pdf file; one report/file for each record.

              Maybe i need to have some sort of filter on the actual report??

              I will see if i can create a similar database to send to you, but this will be difficult.

              Thanks

              Comment


              • #8
                Re: Report.saveas("Dr_Report","rtf")

                AHAH !!!!! I got it!!!!

                The following code WORKS!!!

                ... may be of interest to other folks who encounter the same problem:
                =========================================================
                dim tbl As P
                dim ReportPathFile As C
                dim FileName As C
                dim foldername as C
                dim pathtofolder as C
                dim DrFirstName As C
                dim DrLastName As C
                dim DrCCODEVal As N
                dim Count As N
                dim Counter2 As N
                dim SID2Num[100] As N
                dim DrCCODE[100] As N
                dim PatientFirst[100] As C
                dim PatientLast[100] As C

                tbl = table.current()
                tbl.fetch_first(1)
                pathtofolder = a5.Get_Path() +"\DrFolders\\"

                Count = 0
                while .not. tbl.fetch_eof()
                Count = Count + 1
                'ui_msg_box("SID2 =","SID2 = "+str(tbl.sid2),UI_INFORMATION_SYMBOL+UI_OK)
                SID2Num[Count] = tbl.sid2
                DrCCODE[Count] = tbl.ccode
                PatientFirst[Count] = tbl.firstname
                PatientLast[Count] = tbl.lastname
                tbl.fetch_next(1)
                end while

                'ok... i have all of the SID2 values in a vector (SID2Num[])... i will use these values to specify the save report query

                for Counter2 = 1 to Count
                'get Dr / Client Firstname & Lastname... the DrFolder is named (Client->Lastname + "_" + Client->Firstname) + "(" + alltrim(str(Client->CCODE)) + ")"
                DrCCODEVal = DrCCODE[Counter2]
                DrFirstName = lookupc("F",DrCCODEVal,"Firstname","client","Ccode")
                DrLastName = lookupc("F",DrCCODEVal,"Lastname","client","Ccode")


                foldername = pathtofolder + alltrim(DrLastName) + "_" + alltrim(DrFirstName) +"(" + alltrim(str(DrCCODE[Counter2])) + ")"

                'Check to see if Dr folder exists & if NOT, then create it
                if .NOT. file.exists(foldername)
                DIR_CREATE(foldername)
                'ui_msg_box("Dr FOLDER HAS BEEN CREATED",foldername + " has been created",UI_INFORMATION_SYMBOL+UI_OK)
                end if

                'ok... we have ensured that the DrFolder exists.... save PDF report in this Folder, useing patient Firstname + "_" + patient Lastname + "(" + alltrim(sid2) + ")"


                ReportPathFile = foldername + "\\" + alltrim(PatientFirst[Counter2]) + "_" + alltrim(PatientLast[Counter2]) + "Dr(SID_" + alltrim(str(SID2Num[Counter2])) + ").pdf"

                'Response = ui_msg_box("REPORTING TO...","SID2 = " + alltrim(str(tbl.Sid2,9,0)),UI_ATTENTION_SYMBOL+UI_OK_CANCEL)
                'Response = ui_msg_box("REPORTING TO...",ReportPathFile,UI_ATTENTION_SYMBOL+UI_OK_CANCEL)
                'if Response = UI_CANCEL_SELECTED then
                'STOP
                'end if

                if file.exists(ReportPathFile) then
                file.remove(ReportPathFile)
                end if

                ':Report.saveas("HairReport1stpgV4","pdf","SID2 = " + alltrim(str(tbl.Sid2,9,0)),"",ReportPathFile)
                ':Report.saveas("HairReport1stpgV4","pdf","SID2 = " + alltrim(str(SID2Num[Counter2])),"",ReportPathFile)
                :Report.saveas("HairRepCombinedV4Dr","pdf","SID2 = " + alltrim(str(SID2Num[Counter2])),"",ReportPathFile)
                tbl.fetch_next(1)

                next Counter2

                ===============================================================

                The difference between what i was originally doing & this is that i step through the selected records & get needed data (particularly the query info for the report.saveas statement).

                hope this helps someone

                D

                Comment


                • #9
                  Re: Report.saveas("Dr_Report","rtf")

                  Possibly this is easier to read.

                  Code:
                  dim tbl As P
                  dim ReportPathFile As C
                  dim FileName As C
                  dim foldername as C
                  dim pathtofolder as C
                  dim DrFirstName As C
                  dim DrLastName As C
                  dim DrCCODEVal As N
                  dim Count As N
                  dim Counter2 As N
                  dim SID2Num[100] As N
                  dim DrCCODE[100] As N
                  dim PatientFirst[100] As C
                  dim PatientLast[100] As C
                  
                  tbl = table.current()
                  tbl.fetch_first(1)
                  pathtofolder = a5.Get_Path() +"\DrFolders\\"
                  
                  Count = 0
                  WHILE .not. tbl.fetch_eof()
                  	Count = Count + 1
                  	'ui_msg_box("SID2 =","SID2 = "+str(tbl.sid2),UI_INFORMATION_SYMBOL+UI_OK)
                  	SID2Num[Count] = tbl.sid2
                  	DrCCODE[Count] = tbl.ccode
                  	PatientFirst[Count] = tbl.firstname
                  	PatientLast[Count] = tbl.lastname
                  	tbl.fetch_next(1)
                  END WHILE
                  
                  'ok... i have all of the SID2 values in a vector (SID2Num[])... i will use these values to specify the save report query
                  
                  FOR Counter2 = 1 TO Count
                  	'get Dr / Client Firstname & Lastname... the DrFolder is named (Client->Lastname + "_" + Client->Firstname) + "(" + alltrim(str(Client->CCODE)) + ")"
                  	DrCCODEVal = DrCCODE[Counter2]
                  	DrFirstName = lookupc("F",DrCCODEVal,"Firstname","client","Ccode")
                  	DrLastName = lookupc("F",DrCCODEVal,"Lastname","client","Ccode")
                  	
                  	
                  	foldername = pathtofolder + alltrim(DrLastName) + "_" + alltrim(DrFirstName) +"(" + alltrim(str(DrCCODE[Counter2])) + ")"
                  	
                  	'Check to see if Dr folder exists & if NOT, then create it
                  	IF .NOT. file.exists(foldername)
                  		DIR_CREATE(foldername)
                  	END IF
                  	
                  	'ok... we have ensured that the DrFolder exists.... save PDF report in this Folder, useing patient Firstname + "_" + patient Lastname + "(" + alltrim(sid2) + ")"
                  	
                  	ReportPathFile = foldername + "\\" + alltrim(PatientFirst[Counter2]) + "_" + alltrim(PatientLast[Counter2]) + "Dr(SID_" + alltrim(str(SID2Num[Counter2])) + ").pdf"
                  		
                  	IF file.exists(ReportPathFile) THEN
                  		file.remove(ReportPathFile)
                  	END IF
                  	
                  	:Report.saveas("HairRepCombinedV4Dr","pdf","SID2 = " + alltrim(str(SID2Num[Counter2])),"",ReportPathFile)
                  	tbl.fetch_next(1)
                  	
                  NEXT Counter2
                  There can be only one.

                  Comment

                  Working...
                  X