If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Save report to file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-12, 19:11
manics manics is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Save report to file

I have this code to save a report to file:

Private Sub Command17_Click()

Me.Refresh
On Error GoTo Err_Command17_Click

Dim stDocName As String

stDocName = "rptOperator Log"
DoCmd.OutputTo acReport, stDocName, acFormatPDF, "L:\Operations\Team Managers\" & DatePart("yyyy", Date_of_Log) & " Operator Log\" & Employee_Name & ID & ".pdf"

Exit_Command17_Click:
Exit Sub


Err_Command17_Click:
MsgBox Err.Descriptionq
Resume Exit_Command17_Click

End Sub

The problem I'm having is that everytime it saves,it saves one file with all the records to pdf not just the current one and it also prints at the same time. all i want is to save the current report displayed on the form with the employee name and file ID on pdf. any help with this matter will be appreciated.
thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 01-03-12, 20:03
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
There's nothing there that should print the report. To restrict the report, you've got at least 3 options. One is to open the report in preview mode using a technique like this to restrict it:

Open a second form to the record

and then output it. The second is to base the report on a parameter query that uses the form to restrict the records returned. The third is to adapt this type of thing:

Emailing a different report to each recipient

For outputting, I'd do the third to avoid the overhead of opening the report first but maintain the flexibility of not having parameters in the query.
__________________
Paul
Reply With Quote
  #3 (permalink)  
Old 01-04-12, 13:25
manics manics is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Here is a sample of the database, i just left the form that i need print to file.
Attached Files
File Type: zip testdata1.zip (39.5 KB, 1 views)
Reply With Quote
  #4 (permalink)  
Old 01-04-12, 14:01
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Your actual code includes the line

DoCmd.OpenReport stDocName, acNormal

which is printing the report.
__________________
Paul
Reply With Quote
  #5 (permalink)  
Old 01-04-12, 16:30
manics manics is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
got it.
What is causing the file to save all reports instead of the current one on the form?
Reply With Quote
  #6 (permalink)  
Old 01-04-12, 16:40
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
apply a filter as part of the openreport method
Google
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old 01-04-12, 17:07
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Quote:
Originally Posted by manics View Post
got it.
What is causing the file to save all reports instead of the current one on the form?
You haven't told it to do otherwise. I gave you 3 different ways of doing it in post 2.
__________________
Paul
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On