Export report to PDF Automatically with button

godknow

Registered User.
Local time
Today, 17:42
Joined
Jun 26, 2012
Messages
15
currently i have to open my report and export manually to save report as pdf.
This is my code to open for specific user :
DoCmd.OpenReport "myreport", acViewPreview, , "[User_ID] = " & Me.User_ID

now I want to output my report to pdf automatically to a certain location.

how do i filter with specife userid ... by using DoCmd.OutputTo
DoCmd.OutputTo acOutputReport, "myreport", acFormatPDF, "C:\Users\public\temp\Course " & [UserID] & " - test.pdf", False

is there any other way i accomplish this..
 
You should be able to filter the underlying query -
 
You should be able to filter the underlying query -

Can you explain with an example ... I don't understand " You should be able to filter the underlying query
 
If you keep both lines, you should get a filtered report.
 
modify

DoCmd.OpenReport "myreport", acViewPreview, , "[User_ID] = " & Me.User_ID

to

DoCmd.OpenReport "myreport", acViewPreview, , "[User_ID] = " & Me.User_ID, acHidden

then run your OutputTo

OutputTo does not allow you to use openargs, if you don't want to use OpenReport to provide them then you need to modify your query as previously suggested or have a bit of code in the report on open event to provide the filter

e.g.
Me.Filter="[User_ID] = " & Forms!YourFrm!User_ID
Me.Filteron=True
 
modify

DoCmd.OpenReport "myreport", acViewPreview, , "[User_ID] = " & Me.User_ID

to

DoCmd.OpenReport "myreport", acViewPreview, , "[User_ID] = " & Me.User_ID, acHidden

then run your OutputTo

OutputTo does not allow you to use openargs, if you don't want to use OpenReport to provide them then you need to modify your query as previously suggested or have a bit of code in the report on open event to provide the filter

e.g.
Me.Filter="[User_ID] = " & Forms!YourFrm!User_ID
Me.Filteron=True

Thanks this works ...
 

Users who are viewing this thread

Back
Top Bottom