Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2008

Tip: Looking for answers? Try searching our database.

Problem with VBScript to open a database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Irina - 21 May 2008 15:09 GMT
I have a database with Autoexec Macro in it (which would run when a user
opens the DB) I dont want to open that particular DB manually. So I have a
script that would open the DB and the macro will run (macro just creates a
copy of a certain table with a date appended to the name of the table for
backup purposes). I can not get the script to work. It is a VBScript, and it
says that it is running, however the macro is not being run because there is
no resulting table from the macro.
Here is the code in case you can help with this

Dim objConnection
Dim objRecordSet

Set wshshell = WScript.CreateObject("WScript.Shell")
Set objConnection = CreateObject("ADODB.Connection")

Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
=F:\Litigation\Immigration\Immigration Database\Immigration Reports_BE.mdb;"

MsgBox("Connected to Immigration DB")

WScript.sleep(3000)

MsgBox("close connection")

  objConnection.Close
  WScript.Quit
Albert D. Kallal - 23 May 2008 08:18 GMT
In your actual sample, I don't see anywhere where you're actually launching
MS access.

I am going to suggest that you move your code to a standard module and place
a subroutine in that module in which your code runs and does your series of
processes that you wanted to accomplish. In your example, you're using the
ado library and jet, but not actually launching MS access.

if you try to run a macro, or some DBA code in a standard code module inside
of MS access, then I suggest the following approach.

you can then run a script and execute that subroutine in a standard code
module as follows:

 dim accessApp
 set accessApp = createObject("Access.Application")
 accessApp.OpenCurrentDataBase("C:\some path name\someMdb.mdb")

 accessApp.Run "TimeUpDate"
 accessApp.Quit
 set accessApp = nothing

The above script will launch ms-access, and then run a sub called TimeUpDate
in a standard code module.

what your code does in the standard sub (called TimeUpdate in above) is up
to you. You can print reports, or do whatever you want.

I explain more how to set dispatch file not following article of mine

http://www.members.shaw.ca/AlbertKallal//BatchJobs/Index.html

Signature

Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.