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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Macro Automatically 3

Status
Not open for further replies.

tdonahue

Technical User
Feb 4, 2001
50
US
I have designed a macro to automatically update some of my tables. This macro takes about 15 minutes to run. I was hoping it was possible to have this macro run an hour or so before I start work every day. Is this possible?
 
Thanks, everyone for your help in this matter. What fixed the problem was changing the TimeBox to a text box from a label box and changing the name of the text box to TimeNow.

Using the windows scheduler looks like it would make sense, but after trying to set it up I guess I don't have permission to set up a task, because, when I got to the task Scheduler and went to new the program does nothing.
 
I use the code to try and run my macro but all it does is tell me the time, why doesn't it activate the macro??


Private Sub Form_Timer()
Dim TimeNow As String
TimeNow = Str(Time)
TimeBox.SetFocus
TimeBox.Text = TimeNow
If TimeBox.Text = "3:00 PM" Then
DoCmd.RunMacro "AAADataRefreshMacro"
End If
Exit Sub
End Sub
 
Format your textbox for medium date, read all of the posts in this thread.

Sean.
 
slreynolds,

So my notpad file would be this?:

Dim objAccess
Dim strPathToMDB
Dim strTableName
Dim strFilePath
Dim strMsg


' EDIT with your path and database name
strPathToMDB = "c:\Reports.mdb

' Create Access 2002 Application Object
Set objAccess = CreateObject("Access.Application.10")

' Open the desired database
objAccess.OpenCurrentDatabase(c:\Reports.mdb)

' EDIT with your Macro Name
objAccess.DoCmd.RunMacro "macReportNo"

strMsg = "The macro named" & vbcrlf & " UpdateVendData" & vbcrlf & " execued successfully."
MsgBox strMsg,vbInformation,"Finished"

' Clean up
objAccess.CloseCurrentDatabase
ObjAccess.Quit
Set objAccess = Nothing
 
I changed the text box format to Medium and now I'm getting the following error message: "Compile Error: Can't find project or library" and the debugger stop on Str(Time)
My database is on a server, would this cause the problem??

Private Sub Form_Timer()
Dim TimeNow As String
TimeNow = Str(Time)
TimeBox.SetFocus
TimeBox.Text = TimeNow
If TimeBox.Text = "3:00 PM" Then
DoCmd.RunMacro "AAADataRefreshMacro"
End If
Exit Sub
End Sub
 
I run many tasks using Task Scheduler and find it to be the simplest method. I usually create a DOS Batch file to open the MDB and run the macro. Typical batch file:

START MSACCESS.EXE <Full Path and filename of mdb> /xMACRONAME

Ken
 
I am having problem sheduling task that runs a macro on windows 2000.
I have tried doing it with batch file and also with using
/x command.
same commands work fine from dos or from run.
but by scheduling it from task scheduling or by at command it just hangs.
I am not using system account but admin account.
Same stuff works from another Nt box.
If I schedule it as interactive it works.
 
I used the code similar to:

Private Sub Form_Timer()
Dim TimeNow As String
TimeNow = Str(Time)
TimeBox.SetFocus
TimeBox.Text = TimeNow
If TimeBox.Text = &quot;8:25 AM&quot; Then
DoCmd.RunMacro &quot;RunTotalUpdates&quot;
End If
Exit Sub

It works great to run the macro once. I would like to run the macro every hour. Anyone know how to do that?

 
That's really easy.

Just set up a blank form. In design mode, select properties, then set the Timer Interval property to &quot;3600000&quot; (the timer setting is in milliseconds, so that's one hour, I think).

Under the &quot;On Timer&quot; event, put your code to run the macro (DoCmd.RunMacro &quot;RunTotalUpdates&quot;). You don't have to check the time, or any of that stuff. Leave the form open, and your code will run once an hour.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top