balllian,
Oh, I see. Totally ignored the "three times on Friday thing", didn't I?
Sorry.
Here's a little snippet that will do what you want:
Public Function RunAppendQuery()
'Turn off confirmation messages
CurrentProject.Application.SetOption "Confirm Record Changes", False
CurrentProject.Application.SetOption "Confirm Document Deletions", False
CurrentProject.Application.SetOption "Confirm Action Queries", False
Select Case Format(Date, "ddd")
'Run query once on Mon, Tue, Wed, Thu
Case "Mon", "Tue", "Wed", "Thu"
DoCmd.OpenQuery "Query1"
'Run query 3 times on Fri
Case "Fri"
DoCmd.OpenQuery "Query1"
DoCmd.OpenQuery "Query1"
DoCmd.OpenQuery "Query1"
End Select
'Turn on confirmation messages
CurrentProject.Application.SetOption "Confirm Record Changes", True
CurrentProject.Application.SetOption "Confirm Document Deletions", True
CurrentProject.Application.SetOption "Confirm Action Queries", True
End Function
Just plug the snippet into a module, plug your query name into the code, save the module, set your scheduler to open the database daily, and in your autoexec macro, use the "RunCode" action to run the "RunAppendQuery()" Function.
On Mon, Tue, Wed, Thu, the query will run once.
On Fridays, it will run 3 times.
On Saturdays and Sundays, it will not run.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! A WORD OF CAUTION !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[/color red]
This autoexec macro will run EVERY time you open the database. So, if you are going in to make some change to the query, and you double-click the mdb file to open it, the autoexec macro (and hence, the function), will run, and your table(s) will be appended, even though you probably weren't wanting to do that.
You can, however, bypass the autoexec macro by HOLDING DOWN THE SHIFT KEY [/color red] when you open the database.
Let me know if you have any more problems.
Good Luck,
Tranman