Haiden Turner
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.Appli cation")
accessApp.OpenCurrentDataB ase("C:\Us ers\xxx\xx x.accdb")
set rs = CreateObject("ADODB.Connec tion")
strConnect = "Driver={SQL Server};Server=216.105.115 .189,4250; Database=x xx;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.
My vbscript follows:
Dim rs
Dim accessApp
Dim strConnect
set accessApp = createObject("Access.Appli
accessApp.OpenCurrentDataB
set rs = CreateObject("ADODB.Connec
strConnect = "Driver={SQL Server};Server=216.105.115
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER