473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Running a macro automatically

1
Hello all,

I am trying to make a macro run nightly. I have a task scheduler to open the database, and on the opening form I have put a time interval code set. However, I am unsure what time interval amount I should put. Let's say I put 6000. Upon testing this, it printed the report continuously every 6 seconds.

How can I make it run just once, then stop?

This is the code I used, thanks to a 2007 post on here:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2. If intCounter > 1 Then
  3.   Me.TimerInterval = 0
  4.   DoCmd.Quit
  5. Else
  6.   DoCmd.RunMacro "mcrTest"
  7. End If
  8.  
  9. intCounter = intCounter + 1
  10. End Sub
thanks in advance!
Sep 13 '18 #1
2 2613
Seth Schrock
2,965 Expert 2GB
For other's reference, here is the link to the thread referenced.

I have done this a few times, and I do what was described in post #2
I've never actually done this, and I didn't have the time to test it, but you should be able to run Microsoft Access with the /x macroname Command Line Option as a Daily Scheduled Task if you are using Windows XP. Here is the procedure:
Start Menu
Programs
Accessories
System Tools
Scheduled Tasks
Add a Scdeduled Task
Select Program to Run
Add any necessary Parameters
Select Open the Advance Properties Dialog when finished
Specify the /x macroname Command Line Option on the Command Line
Have your macro call a function that runs your report and then closes the database. You don't need any of the timer form or the If-then-else statement.
Sep 13 '18 #2
NeoPa
32,556 Expert Mod 16PB
You can find some extra info at Invoking a Database From the Command Line.
If you want to run it once only, every time it's opened then include the following code at the end :
Expand|Select|Wrap|Line Numbers
  1. Call Quit(Option:=acQuitSaveNone)
Sep 13 '18 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alfred | last post by:
hi all, i'm trying to figure out if there is some easy way to run a python script in the background _without_ specifying "&" in a linux enivornment. script.py & vs
2
by: E Harris | last post by:
Hello all. I want to schedule an Access macro to run. The macro runs 3 make-table queries. The best way I thought to accomplish this is to create a shortcut, and then use the task scheduler...
2
by: CS_112_smk36 | last post by:
I have a button setup to run a macro that does a OutputTo command on a query to Excel 97-2003. The macro runs fine, but after it is done for some reason the SQL code in the query is deleted and it...
2
by: diegoagallo | last post by:
I need to use the arrow keys while a macro is running, is this posible?
2
by: mscurto | last post by:
Is there a way to set up access to open and run a query in a particular database at a particular time each day? This would be run from a Windows 2000 desktop.
4
by: JJ | last post by:
I am trying to setup a window tasks (or other better method) that runs aspx page once a day. How do I do this? Thanks
0
by: longtone | last post by:
Is it possible to set the server to automatically update a database every hour, even if my compueter is offline. I am using php mysql
5
by: ConfusedMay | last post by:
Hi Experts, I just want to know if it's possible to schedule run macro in access 2003 automatically every night, so users can see the updated data early in the morning without have to wait for me...
2
by: jmartmem | last post by:
Greetings, I have several Access 2007 reports that I regularly export to individual PDF flat files on a web server. I've successfuly created a module sub to export the reports using the...
3
by: flow3rgirlz | last post by:
Hi all, I'm really new to Perl. I'm not sure where to post my topic as it between Perl and Visio. Anyway, I want to run a Visio macro automatically using Perl Script. $vis->Run($macro_to_run);...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.