Do I need to pause this script?

G

Guest

This database is set up so that when I open it up, a form loads that has
about 12 sequenced events that run one after the other to update the data
every day.

I want to run the following script:

Option Explicit

Dim oJet 'As DAO.DBEngine
Dim oDB 'As DAO.Database

Const DB_NAME = "FullPathToDatabase.mdb"

Set oJet = CreateObject("DAO.DBEngine.36")
Set oDB = oJet.OpenDatabase(DB_NAME)

oDB.Close


Is there anything I need to use to pause between the Opendatabase and
oDB.Close to allow the events enough time to run? Are there any opinions
about doing this?

Thank you
 
R

Roger Carlson

If you intend for this to open the other Access application, open a form,
and run events, you'll be disappointed. OpenDatabase ONLY opens the
database, not the Access database application. There is a difference. In
order to do what you want, you could use the Shell command to open the
Access database file with the /x switch. This will execute a macro which
could contain all your commands or just run a function that executes all
your command. Then at the bottom of you code, (in the remote database) you
close the application.

Something like this:
Set db = CurrentDb

Filename = "\RemoteMacro.mdb"
ExecutionMacro = " /xAutoRun"
'the directory where the application lives
Directory = getpath(db.Name)
'finds where Access itself lives
AppPath = SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"
'MsgBox AppPath & " " & Directory & Filename
htask = Shell(AppPath & " " & Directory & Filename & ExecutionMacro, 1)

This code will open the external database, excuting the AutoRun macro. This
macro calls some code then quits.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "RunRemoteMacro.mdb" which illustrates how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
G

Guest

Thank you Roger, I'll look at your example and try to get this working, I'll
post back with questions. I appreciate your help.
--
Jeff C
Live Well .. Be Happy In All You Do


Roger Carlson said:
If you intend for this to open the other Access application, open a form,
and run events, you'll be disappointed. OpenDatabase ONLY opens the
database, not the Access database application. There is a difference. In
order to do what you want, you could use the Shell command to open the
Access database file with the /x switch. This will execute a macro which
could contain all your commands or just run a function that executes all
your command. Then at the bottom of you code, (in the remote database) you
close the application.

Something like this:
Set db = CurrentDb

Filename = "\RemoteMacro.mdb"
ExecutionMacro = " /xAutoRun"
'the directory where the application lives
Directory = getpath(db.Name)
'finds where Access itself lives
AppPath = SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"
'MsgBox AppPath & " " & Directory & Filename
htask = Shell(AppPath & " " & Directory & Filename & ExecutionMacro, 1)

This code will open the external database, excuting the AutoRun macro. This
macro calls some code then quits.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "RunRemoteMacro.mdb" which illustrates how to do this.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
D

dbahooker

you don't need to pause it

but you do need to change it to ADO

I mean get with the times kids
 

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