Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting VBA into VBScript

Status
Not open for further replies.
May 25, 2005
35
US
I have a piece of code that I wrote in VBA that I need to convert to VBScript.

DoCmd.TransferDatabase acImport, "ODBC", "ODBC;DSN=CareVue;UID=xxxxx;PWD=xxxx", acTable, "tablename", "tablename"

Could someone please help me?
 
Just give the docmd a reference to the top application object. If it is called oaccess, then it becomes this.
[tt] oaccess.docmd.transferdatabase ...[/tt]
Or you can set up object of its own.
[tt] set docmd=oaccess.docmd
docmd.transferdatabase ...[/tt]
Then you have define your constants, once read from the lib in the vba.
[tt] const acImport=0
const acTable=0[/tt]
- tsuji
 
I may be wrong, but this appears to need Access to run. I do appreciate the suggestion, but we’re going to be running this code on a server and would prefer not to have Access running. The script will be ran within SQL Server 2000. I guess I should have included that in my initial post.
 
DoCmd is a property of the Access.Application object.
I don't know how you can use it without an instantiation of access.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The only way I could think to do it would be to have access and the db on a client machine. Then the server could remotely run the script on the client. Seems overcomplicated to me, but it keeps access from being installed on the server.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I think it is time I give a full background to the question. Perhaps it will help you to give me the answer I seek. We have a program called CareVue. It has an AllBase database. We have an ODBC driver for it. What we want to do is have the SQL Server import the data/tables from AllBase into it on a regular basis. Since I was more familiar with Access than I am with SQL Server, I wrote a “model” VBA script in it (Actually I created a macro and then modified the code from it). This code worked great. Now, I need to write the script (either jscript for VBScript) for the SQL Server so we can incorporate it into a procedure. I hope I am making sense, as my screen name indicates I am an intern and am learning as I go.
 
Why not posting in a SQL Server forum ?
I know SQL Server may work with foreign tables.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top