|
-
Jan 16th, 2006, 08:22 PM
#1
Thread Starter
New Member
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
-
Jan 16th, 2006, 09:00 PM
#2
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:
Private Sub Export_Reports()
Dim rptTemp As AccessObject
Dim sPath As String
sPath = "C:\Reports\"
DoCmd.SetWarnings False
For Each rptTemp In Application.CurrentProject.AllReports
DoCmd.OutputTo ObjectType:=acOutputReport, _
ObjectName:=rptTemp.Name, _
OutputFormat:=acFormatRTF, _
OutputFile:=sPath & rptTemp.Name
Next rptTemp
DoCmd.SetWarnings True
End Sub
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Jan 16th, 2006, 09:59 PM
#3
Thread Starter
New Member
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
-
Jan 16th, 2006, 10:05 PM
#4
Thread Starter
New Member
Re: saving reports
Nevermind I figured it out, thank you so much.
-
Jan 16th, 2006, 10:44 PM
#5
Thread Starter
New Member
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
-
Jan 16th, 2006, 10:50 PM
#6
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 
-
Jan 16th, 2006, 11:11 PM
#7
Thread Starter
New Member
Re: saving reports
 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.
-
Jan 16th, 2006, 11:39 PM
#8
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|