473,566 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ran a batch file or an MS Access macro shortcut without opening another instance of access

I am trying to use Windows Task Scheduler to run a batch file for an
already open MS Access database. Below is the syntax to the batch file:

Batch file: DailySalesExpor t.bat
REM This runs the macro that exports the reports to the J drive
PATH = "C:\Program Files\Microsoft Office\Office\; C:\Windows\Comm and"
START /WAIT Msaccess.exe "D:\acesdata\SA LES\Daily2005.m db" /x
"SnapShotExport DailySales"
EXIT

Its working fine, the only problem is that its opening another instance
of MS Access and i dont want it to do that since that databse is
already open. I have to live it open because the main form has criteria
which the database uses.

I tried saving a shortcut of the macro to my computer:

D:\acesdata\SAL ES\BatchFiles\S napShotExportDa ilySalesReports .MAM

This works fine when i double click on it from windows explorer but
when i use scheduler to run it opens another instance of ms access too!

Please help

Cliff

Nov 23 '05 #1
4 26801
This may not be worth much, but I have not had much luck with the
Windows scheduler. I write my own schedulers in either VB6 or VB.Net.
You have way more control over Access with a VB app. You can invoke
Access or check if an instance of Access is already running (just check
if the corresponding ldb file is alive). If it exists, then don't
invoke Access. If there is no ldb for that file, then invoke Access.
You can run subs in Access from a VB app.

Sub RunAccess()
Dim AccApp As Access.Applicat ion
AccApp = CType(CreateObj ect("Access.App lication.10"),
Access.Applicat ion)
AccApp.OpenCurr entDatabase(App lication.Startu pPath & "\AccessDB1.mdb ")
AccApp.Run("sub GetData", d1.ToShortDateS tring)
AccApp.CloseCur rentDatabase()
AccApp.Quit()
End Sub

This is a sample VB.Net sub. You create the Access Object, open an
Access mdb (which happens to be in the same directory as the VB app --
Application.Sta rtupPath), you run a sub in Access (subGetData) and pass
in an argument (a date arg here)

AccApp.Run("sub GetData", d1.ToShortDateS tring)

When the sub is done, you close Access. The sub runs synchronously here
- means you won't go to the next line of code in the VB app until Access
finishes runnning the sub. Then you close Access down and quit the
Object.

You can set a Timer object in the VB app and set that to run based on
your specs, hourly, daily, twice a day, etc. Way more flexibility than
the Windows Scheduler. Way more reliable.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Nov 24 '05 #2
Look at scheduling a script file instead. You can then use createobject to
get the current instance of Access and run the macro using automation.

--
Terry Kreft

"CliffKing" <cl*****@msn.co m> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I am trying to use Windows Task Scheduler to run a batch file for an
already open MS Access database. Below is the syntax to the batch file:

Batch file: DailySalesExpor t.bat
REM This runs the macro that exports the reports to the J drive
PATH = "C:\Program Files\Microsoft Office\Office\; C:\Windows\Comm and"
START /WAIT Msaccess.exe "D:\acesdata\SA LES\Daily2005.m db" /x
"SnapShotExport DailySales"
EXIT

Its working fine, the only problem is that its opening another instance
of MS Access and i dont want it to do that since that databse is
already open. I have to live it open because the main form has criteria
which the database uses.

I tried saving a shortcut of the macro to my computer:

D:\acesdata\SAL ES\BatchFiles\S napShotExportDa ilySalesReports .MAM

This works fine when i double click on it from windows explorer but
when i use scheduler to run it opens another instance of ms access too!

Please help

Cliff

Nov 24 '05 #3
Dum, dum, dum...

Strike CreateObject ... insert GetObject.

Fingers running faster than head.
--
Terry Kreft

"Terry Kreft" <te*********@mp s.co.uk> wrote in message
news:CP******** ************@ka roo.co.uk...
Look at scheduling a script file instead. You can then use createobject
to get the current instance of Access and run the macro using automation.

--
Terry Kreft

"CliffKing" <cl*****@msn.co m> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I am trying to use Windows Task Scheduler to run a batch file for an
already open MS Access database. Below is the syntax to the batch file:

Batch file: DailySalesExpor t.bat
REM This runs the macro that exports the reports to the J drive
PATH = "C:\Program Files\Microsoft Office\Office\; C:\Windows\Comm and"
START /WAIT Msaccess.exe "D:\acesdata\SA LES\Daily2005.m db" /x
"SnapShotExport DailySales"
EXIT

Its working fine, the only problem is that its opening another instance
of MS Access and i dont want it to do that since that databse is
already open. I have to live it open because the main form has criteria
which the database uses.

I tried saving a shortcut of the macro to my computer:

D:\acesdata\SAL ES\BatchFiles\S napShotExportDa ilySalesReports .MAM

This works fine when i double click on it from windows explorer but
when i use scheduler to run it opens another instance of ms access too!

Please help

Cliff


Nov 24 '05 #4
Thanks for your help

Rich P wrote:
This may not be worth much, but I have not had much luck with the
Windows scheduler. I write my own schedulers in either VB6 or VB.Net.
You have way more control over Access with a VB app. You can invoke
Access or check if an instance of Access is already running (just check
if the corresponding ldb file is alive). If it exists, then don't
invoke Access. If there is no ldb for that file, then invoke Access.
You can run subs in Access from a VB app.

Sub RunAccess()
Dim AccApp As Access.Applicat ion
AccApp = CType(CreateObj ect("Access.App lication.10"),
Access.Applicat ion)
AccApp.OpenCurr entDatabase(App lication.Startu pPath & "\AccessDB1.mdb ")
AccApp.Run("sub GetData", d1.ToShortDateS tring)
AccApp.CloseCur rentDatabase()
AccApp.Quit()
End Sub

This is a sample VB.Net sub. You create the Access Object, open an
Access mdb (which happens to be in the same directory as the VB app --
Application.Sta rtupPath), you run a sub in Access (subGetData) and pass
in an argument (a date arg here)

AccApp.Run("sub GetData", d1.ToShortDateS tring)

When the sub is done, you close Access. The sub runs synchronously here
- means you won't go to the next line of code in the VB app until Access
finishes runnning the sub. Then you close Access down and quit the
Object.

You can set a Timer object in the VB app and set that to run based on
your specs, hourly, daily, twice a day, etc. Way more flexibility than
the Windows Scheduler. Way more reliable.
Rich

*** Sent via Developersdex http://www.developersdex.com ***


Nov 24 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11012
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after setting stDataSource and stFileName to the desired values. Most of the time it works, but occasionally, typically as code changes are being made to...
4
47459
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup) 4) Once the copy is complete, the batch file opens the Access database again 5) EXIT should close out the cmd window but it does not execute that...
1
3152
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS...
9
5235
by: John | last post by:
Tried this on microsoft.public.access.gettingstarted - no response - perhaps more appropriate here. I'm not a database user, simply helping someone get started with a new computer. The old computer (win98se) runs a database in MS Access 97 pro, with all the attendant permissions etc. I can work on the database without problems, once...
4
2477
by: Jamey Shuemaker | last post by:
A2k2 with user-level security and all preventive measures, vis a vis, Security FAQ enabled or enacted. I've got three DBs, which due to size constraints can't, or rather, probably shouldn't be combined. All have front-end on C: drive, back-end in same folder on network share. All are secured with the same ..mdw. I'd like to make a master...
4
12420
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
4
7871
by: Wayne | last post by:
How do I get rid of the generic Windows "Open File - Security Warning" that appears when I try to open a database that resides on another PC on my home network? This is not the annoying macro security warning - I have my macro security set to low. The warning I am describing only appears when a database on another machine is opened.
0
2323
by: Mark Gold | last post by:
Hi! We have a VB application using Crystal Reports 6 that has worked successfully on hundreds of systems for over 10 years. Now, on one network, the application and access database does not close. It seems to hang on the command. When we open the application an peruse the screens without opening up a report (using crystal reports), the...
0
2902
by: ARC | last post by:
Hello all, For right-click (shortcut) menus in access 2007, I've been using a round-about method of opening access 97 on an old computer, modifying my own custom shortcut menus, then importing the menus only into my access 2007 project. This is proving cumbersome (especially since my old pc with access 97 likes to blue screen when...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.