Link to home
Create AccountLog in
Avatar of Haiden Turner
Haiden TurnerFlag for United States of America

asked on

How run Access query in background using VBscript to connect to SQL Server view with ODBC?

In a VB script I am trying to automate an Access query that uses ODBC to connect to a remote SQL server view.  The code gets the Access database to open, however when the macro runs the query -I am still getting the SQL Server login where I have to provide a password.  I want do run this query behind the scene.  What am I doing wrong?


My vbscript follows:

Dim rs
Dim accessApp
Dim strConnect

set accessApp = createObject("Access.Application")
accessApp.OpenCurrentDataBase("C:\Users\xxx\xxx.accdb")

set rs = CreateObject("ADODB.Connection")
strConnect = "Driver={SQL Server};Server=216.105.115.189,4250;Database=xxx;UID=xxx;PWD=xxx"
rs.Open strConnect

accessApp.DoCmd.RunMacro "UpdateQuickbooks"
accessApp.Quit
set accessApp = nothing

Please help!  New to scripting, and I have tried multiple itterations.
ASKER CERTIFIED SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Haiden Turner

ASKER

Didn't help.