Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Code to Open DB and Permit Working with Tables

Keywords:   open db and permit working with tables

This combination gives your script the capacity to get at the widest range of methods and properties.

In debugging some OLE exceptions for a script I need completed by tomorrow, I discovered something which may be helpful to others:

In order to use Methods and Properties from both the Application Object and the DBEngine Object when using OLE with Microsoft Access via Winbatch Scripts, the following is required:

oMDB = ObjectOpen("Access.Application.8")
APP = oMDB.Application
; this 'opens' the Database and permits working with tables
; from the DoCmd Object - this would allow functions like
; Cmd.TranserDatabase()
APP.OpenCurrentDatabase("E:\WBDEMO\BLANK.MDB")
Cmd = APP.docmd

; now set your object from oMDB, not APP
Dao = oMDB.DBEngine
ws = Dao.CreateWorkspace("JetWorkspace", "admin", "")

; this method does not really open the database, but sets a 'pointer'
; to it, so you can perform actions like creating queries
; qdef = db.CreateQueryDef("ccqry","SELECT ANI FROM TEMPTBL")
db = ws.OpenDatabase("E:\WBDEMO\BLANK.MDB")

Article ID:   W14909