Results 1 to 8 of 8

Thread: saving reports

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    11

    saving reports

    What i'm trying to do if its possible is beable to save each report in my database and save it as an .rtf or .doc into a directory on my c: drive i.e. (C:\reports) programically, where I do not have to specifically save each report individually. If possible I would like to do this on a botton click where It would call a module and automatically save each report in my database into the directory path. Can this be done? Please let me know! Or point me in the right direction. Thanks.

    James

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: saving reports

    The following should give you a start.
    Basically I'm looping through each report in the "AllReports" collection and calling the OutputTo method to save a copy to a specified path.

    VB Code:
    1. Private Sub Export_Reports()
    2. Dim rptTemp As AccessObject
    3. Dim sPath As String
    4.  
    5.     sPath = "C:\Reports\"
    6.        
    7.     DoCmd.SetWarnings False
    8.    
    9.     For Each rptTemp In Application.CurrentProject.AllReports
    10.         DoCmd.OutputTo ObjectType:=acOutputReport, _
    11.                         ObjectName:=rptTemp.Name, _
    12.                         OutputFormat:=acFormatRTF, _
    13.                         OutputFile:=sPath & rptTemp.Name
    14.     Next rptTemp
    15.    
    16.     DoCmd.SetWarnings True
    17. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    11

    Re: saving reports

    DKenny, thank you the code you provided worked great I was able to save my reports to that directly. Only thing is that it requires me to select the program to open up the report. Is there a way i can give it an extention of .rtf or .doc because without the extention is requiring me to select the correct program to open it with. Thanks again

    James

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    11

    Re: saving reports

    Nevermind I figured it out, thank you so much.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    11

    Re: saving reports

    Actually there is just one more thing, possibly you can help me out. What I would like to do now is create a hyperlink dynamically to that report I just saved into my table. This will be used mostly for the web based application. Everytime I save a report I would like the path of the report to be saved into a hyperlink field in the table. So for example if I had a Demographics form in the demographics table I would like to have a field which will hold the hyperlink for the location i just saved for that report included in the table so when I place the DB onto the webserver all they have to do is click the hyperlink to bring up the report. Now does this make any sense?

    James

  6. #6
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: saving reports

    Yes that makes sense. Are you using ADO or DAO to poulate your forms or are they bound to the table?
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    11

    Re: saving reports

    Quote Originally Posted by DKenny
    Yes that makes sense. Are you using ADO or DAO to poulate your forms or are they bound to the table?
    my forms are bound to the table.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    11

    Re: saving reports

    Also since I'm saving the reports based off a query criteria, being I can have more then one report per table, is there a way I can include the criteria as part of the file name? Im trying to figure out how to do that. Take for example the criteria would be 0001, how would I include that into the file name so when it saves it has its own unique name because right now the way its set up it doesn't matter what criteria it is it will always over right what is in the folder with the new report with the different critiera i don't want that I would to have a new report saved based on the new criteria. Sorry for all the questions, i'm not quite sure how to do all of these. I know a few basic things with VBA but im not a expert. Thanks alot of your help.

    James

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width