One last thing Albert,
if I am putting this on a machine without Access installed I'm getting an
error
"ActiveX component cant create the object access.application"
Is there a workaround for this?
Well, that code is saying:
please launch ms-access.
please run this code in a module in ms-access
please shut down ms-access.
I would expect you realize that a script that tells the computer to load
ms-access, and then run code inside of ms-access is going to requite
ms-access on it!
It is true that every windows xp box ships with the jet data engine, and you
certainly don't need ms-access to read, and write data to a mdb file. (it is
the JET engine that does this...not ms-access). So, you can by-pass using
ms-access. You never did need ms-access on a compute to read data from a mdb
file.
However, to run code in a ms-access module...you are going to need ms-access
installed.
However, you can well eliminate the vb code, and simply execute/run your sql
directly in your vbs script....
Set dbeng = CreateObject("DAO.DBEngine.36")
strMdbFile = "C:\Documents and Settings\Albert\My
Documents\Access\ScriptExample\MultiSelect.mdb"
Set db = dbeng.OpenDatabase(strMdbFile)
strQuery = "select * from contacts"
Set rs = db.OpenRecordset(strQuery)
So, you can well dump the use of ms-access, and don't use a code module. If
you don't load ms-access, then you don't need it!!!
I not sure if you can use linked tables directly in a script however. (I
think you need ms-access for that -- you just have to test this)
Thus, you might need somting like (in addtion to the above script):
Set wrk1 = DBEngine.CreateWorkspace("TestWorkSpace", "", "", 1)
strCon = "ODBC;driver={SQL Server};DSN=;" _
& "SERVER=192.168.1.101;" _
& "DATABASE=RidesSql;" _
& "UID=SA;PWD="
Set MyCon = wrk1.OpenConnection("mycon", dbDriverNoPrompt, False, strCon)
' now, you have a regular connection, and can build a recordset as
' normal...
Set rstRecords = MyCon.OpenRecordset("select * from tblJunk")
The above code is in VBA...you might have to tweak it a bit (but, I would
try/test the linked table in dao, and see if that works....