task scheduler macro

G

Guest

I'm doing a task scheduler macro that is deleting data from a table and then
adding
a new data there.
"C:\Program Files\Office\Office11\msaccess.exe" "C:\SomePath\MyDB.mdb"
/x mcrMacro
Everything is working.
But, I'm getting MS Access worning notifivcations before rows deleting and
append query.
How could I avoid it?
I was trying to use a function in a module with the same queries and
DoCmd.SetWarnings False
substituting the mcrMacro with the funFunction in the task schedular run line.
But the task scheduler is giving an error message saying it cannot find the
macro with that function name.
Probably it should be something else instead of /x in the Task Schedular
line for function.

YThanks
 
T

Tim Ferguson

But, I'm getting MS Access worning notifivcations before rows deleting
and append query.
How could I avoid it?

Use db.Execute instead of DoCmd.RunSQL

or wrap the whole lot inside DoCmd.SetWarnings methods.

"msaccess.exe" "C:\SomePath\MyDB.mdb" /x mcrMacro
I was trying to use a function in a module with the same queries and
DoCmd.SetWarnings False
substituting the mcrMacro with the funFunction in the task schedular
run line. But the task scheduler is giving an error message saying it
cannot find the macro with that function name.

I don't think the /x switch will find a vba routine -- I thought it had
to be a macro that called the RunCode action. If it were to work, then
the routine would have to be a Public Function (not a sub) and return no
return value.

Hope that helps


Tim F
 
G

Guest

Thanks, Tim.

The problem is I have no idea how to include DoCmd.SetWarnings False or
db.Execute into the macro. I can open the macro only in a disign view.

How can I see the macro's code?

Thanks
 
D

Douglas J. Steele

There's a SetWarnings Action as well, which works in Macros.

Just a comment, though: if you're using Macros, why are you posting to the
Modules newsgroup?
 
T

Tim Ferguson

Just a comment, though: if you're using Macros, why are you posting to
the Modules newsgroup?

I assumed that he or she was using VBA (from the mention of
DoCmd.SetWarnings) but was calling it a Macro because that's what you are
told to call it in Word, Excel, PowerPoint etc etc.

I must get that new Windows Telepathy SDK download...

All the best


Tim F
 
T

Tim Ferguson

The problem is I have no idea how to include DoCmd.SetWarnings False
or db.Execute into the macro. I can open the macro only in a disign
view.

As Douglas has intimated, are we talking about VBA or access macros here?
It's not the same as in Word and Excel, where VBA routines are called
macros... in Access they are two separate programming methods.
How can I see the macro's code?

If you click the Macros button in the Database Window, pick one of the
objects there, and click design; they you are looking at the macro code.
It looks like a grid with three or four columns and a list like this:

RunCommand
RunCode
OpenForm

If you click the Modules button in the Database window, pick one of the
objects there, and click design; then you are looking at a much more
complex development environment with a text window with something like

Public Function LogLogin() ' void
Dim jetSQL As String

jetSQL = "INSERT INTO Logins (LoginTime, UserID) " & _
"VALUES (" & _
Format(Now(),"\#yyyy\-mm\-dd hh\:nn\:ss\#, ") & _
"""" & UserID() & """);"

DoCmd.RunSQL jetSQL, dbFailOnError

End Function


Depending on which one you are using, you'll need different techniques!
In general, if you have a choice, VBA routines are much more flexible and
powerful.

Hope that helps


Tim F
 
D

Douglas J. Steele

Slight typo, Tim.

Presumably you mean

CurrentDb.Execute jetSQL, dbFailOnError

rather than

DoCmd.RunSQL jetSQL, dbFailOnError
 
T

Tim Ferguson

Presumably you mean

CurrentDb.Execute jetSQL, dbFailOnError

rather than

DoCmd.RunSQL jetSQL, dbFailOnError

Deliberate mistake to see if anyone was reading that carefully! Actually I
was hoping someone would ask what the second parameter was all about and
that would lead to a discussion of why db.execute is better than
docmd.runsql.

I should have known it wouldn't get past you though!

All the best


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top