Link to home
Start Free TrialLog in
Avatar of Rob4077
Rob4077Flag for Australia

asked on

Does a VBScript editing an Access database run with 2007 Runtime?

Does anyone know if the following vbScript code will work on a PC that only has MS Access 2007 runtime, not the full MS Access?

   Dim appAccess
   Dim strDBNameAndPath
   Dim dbe
   Dim dbs
   Dim strSQL

   Set appAccess = _
      WScript.CreateObject("Access.Application")
   Set fso = _
      WScript.CreateObject("Scripting.FileSystemObject")
   strDBNameAndPath= "C:myFolder\myApp.mdb"
   
On Error Resume Next

   Set fil = fso.GetFile(strDBNameAndPath)
   If fil Is Nothing Then
      strPrompt = "Can't find " & strDBNameAndPath& _
         "; canceling"
      MsgBox strPrompt, vbCritical + vbOKOnly
      Quit
   Else
      Set dbe = appAccess.DBEngine
      Set dbs = dbe.OpenDatabase(strDBNameAndPath)
   
      Set rst = dbs.OpenRecordset("tblMyTable")
      Do Until rst.EOF
         rst.edit
       rst.[Description] = rst.[Description] & "."
       rst.update
      rst.MoveNext
      Loop
      rst.Close
   
   End If

   Set rst = Nothing
   Set appAccess = Nothing
Avatar of ltlbearand3
ltlbearand3
Flag of United States of America image

No it will not run on a machine without access installed since you are using the access object in your code ( Set appAccess = WScript.CreateObject("Access.Application").  That creation step requires Access.  You can re-write this using ADO to get access to the database.  Let me know if you need help with getting it into new code.  If I get a chance I may just do it anyway.
ASKER CERTIFIED SOLUTION
Avatar of ltlbearand3
ltlbearand3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob4077

ASKER

Hi Bear, That appears to be just what I need. You said << It should work on a machine without access installed >>. You mean as long as the runtime version is installed or will it work even without runtime installed? Is it going to foul up registries if there machine has both runtime 2007 and another version of MS Access installed? It looks to me like this will be a perfect solution for me if it works that way.
The could is not fully tested and that is what I mean by should.  It uses the Jet driver which will be on many machines by default, but you may need to install the run time on some.  You will need to just test just to verify.
Avatar of Rob4077

ASKER

That is fantastic. I will test and refine it, no problems. I only asked in case you knew. Appreciate your kind assistance.


Rob