OutputTo Filter Criteria

Ste4en

Registered User.
Local time
Today, 18:17
Joined
Sep 19, 2001
Messages
142
I am trying to publish a report to our server using the following code. I have an input form which sets the date of the report Me![SetDate]- this all works fine however when the OutputTo ac-report line runs, it requests a date parameter from the query on which the report is based - ptc Date, I want this date to be the date Me![SetDate] however the outputTo criteria does not seem to have a filter function? like OpenReport (e.g DoCmd.OpenReport stdocname, acViewPreview, , stlinkcriteria)


Any ideas
Thanks



Dim outputSNP As String
Dim dataDate As String

dataDate = "ptc Date=" & Me![SetDate]

outputSNP = "j:\umps\this week\" & "Clock Hours for-" & Me![SetDate]
& ".snp"

DoCmd.OutputTo acReport, "DailyClockReport_All Employees", acFormatSNP,
outputSNP, False
 
Change the actual recordsource of your report to be based on the text box on your form. This will fix your problem. One thing though, if you are opening your report from other sources, that form with the data must also be open. Otherwise you will basically have the same problem. If you are using it several places, then maybe your should set the recordsource for the report in code at runtime.
 
I can't change the record source of the form. As it presently exists the form accepts the date entered which becomes part of the file name. The report which I am trying to send to the file is based on a query which requires a date parameter. So after I start the procedure I need to tell it to use the Me![SetDate] as the date.

I don't know whether you answer works for this - in any case would appreciate more explaination

thanks
 
Change the recordsource of the report not the form. Go to the recordsource of your report by opening it in design view, opening the properties box, selecting the report, selecting the recordsource row and pressing the ellipse button ( ... ) to the immediate right of the properties line. When you select this it will take you to the query builder window. In the criteria for the date field put in something like this:

forms!MyFormName.MyDateFieldFromForm

That way when you open the report, it will look to your form for the criteria for the date. (Form must be open) Keep in mind, you cannot use the ME keyword, you must use the format I gave above.

Post if you are still having problems.
 

Users who are viewing this thread

Back
Top Bottom