Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run a report automatically

Status
Not open for further replies.

MrMcFestoe

Technical User
Apr 6, 2003
119
GB
I have posted before on this and get some ideas back, but never been able to complete this, i want a report to run when a date field = todays date.

What i have is a table of customers and one of the fields is date to apply when date to apply = todays date it runs the report for that customer only.

Has anybody managed to get reports to run automatically.

Thanks
 
I am assuming you are working on a Form, and one of the fields in the form is a Date Field.

If so, you can put the following code on your date field's AfterUpdate event
If Me.YourDateFieldName = Date() Then
DoCmd.OpenReport "YourReportName"

You will have to continue the code to indicate whether you want the report to run in Preview or Print mode.

Tom

 
Tom

Thanks for the reply in cant be that easy can it?

I have been trying for 6months.

Iam going to try it today

Thanks
 
You really need to describe "run automatically". I take this to mean that at some point each day, Access will start up and run your report without any intervention. Is this what you mean?

Duane
MS Access MVP
 
I see what dhookom means. Since you referred to running a report for "that customer only" I assumed this was taking place from an input form. Now, when I read it again, in light of Duane's comment, I see greater depth to the problem, requiring fuller explanation.

I will be interested in your reply.

Tom
 
Guys

What i have is a letter (Stored as a report) that needs to be printed when the CURRENT DATE = DATE TO APPLY the date to apply is located in my main table called TABLE1. Normally there would not be any customer who need this letter so in most instances the DATE TO APPLY would be empty and no reports would be run, but there is always the occasion where we need to apply so then the field could have a date in it ddmmyyyy.

I am trying to get this report printed automatically without any user intervention.

Is this any help, and iam not very good at decribing what i mean, but i get there in the end.
 
Okay. Let me take a run at this. If there's a better approach, I'm sure Duane will know. If you want absolutely no user intervention at all, I'm not sure how to do that, but there may be a way. In any event, if you could live with "minimum" user intervention, I'm wondering if this would work.

1. Design a query based on your table. One of the fields in that table will be [DateToApply]. Set criteria for that field to Date(), so that it pulls up only those records where the DateToApply is the current date.
2. Base your report on that query.
3. On your main switchboard, put a command button that runs the report. You might also want to put a message box on the reports "No Data" property, indicating there are no letters to be processed today.

Tom

 
You can set up the report with a criteria in the [Date To Apply] field of Date(). This should limit your report to the records you have requested.

Create a macro to print the report.

Then, use the scheduler application found in the downloads at to run the mdb with a command line argument that runs the macro.

Duane
MS Access MVP
 
Duane,

Could i not have DATE TO APPLY = DATE() DoCmd.PrintReport "APPLY"

in a the code for the field DATE TO APPLY,

Looking for ideas on this.

Thanks
 
Look in Help for DoCmd.OpenReport. I don't understand what you are asking. A guess is that you can use:
DoCmd.OpenReport "rptYourReport", , ,"[Date To Apply]= #" & _
Date() & "#"
Is your date field actually in the format ddmmyyyy or is it an actual date field. If it is in this format then try:
DoCmd.OpenReport "rptYourReport", , ,"[Date To Apply]= """ & _
Format(Date(),"ddmmyyyy") & """"



Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top