Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2009, 08:43 AM
Registered User
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default execute batch file

hello,
I am new to vba and I was requested to place the following command in an access database

Code:
CMD.BAT 01-01-000 FROM 00 TO 00
please give me detail where to place this command to run automatically.

thanks
 
Old April 6th, 2009, 08:42 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Normally you attach code to specific events. For example, if you had a main form in your database that opens when the database is opened, you could attach your code to the On Open or On Load event of the form, and it would run "automatically" when you opened the form. If you wanted this to run on a periodic basis, you could attach this to an On Timer event, but the database would have to be open all the time.

If you need this to run on a host machine, perhaps you can create a scheduled event to run this code, wihtout using Access.

In any event, if you want to run this from VBA, you will need to do something like this (assuming that you have a proper path set for the cmd.bat file):

Code:
Dim objShell as Variant
Dim objExecObject As Variant
 
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("%comspec% /c CMD.BAT 01-01-000 FROM 00 TO 00")
Did that help?
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoking a batch file from servlet vinayreddy Servlets 3 October 24th, 2008 02:12 AM
running a batch file from cmd from C# Bill_Thompson C# 2 March 29th, 2008 07:56 AM
Need Help with DOS batch file .. Arul20 Forum and Wrox.com Feedback 5 August 31st, 2007 06:51 AM
Batch File Allan320 Access 10 June 8th, 2006 06:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.