Striker1234
New Member
- Joined
- Dec 12, 2015
- Messages
- 9
Hi,
I am trying to run an MS Access queries from Excel but when I try to run the from Excel, it always asks for a password. I would like to remove the prompts / embed credentials so macro would run without any interruptions.
Thanks in advance!
AQuery is an Append Query that goes to ATable
I am trying to run an MS Access queries from Excel but when I try to run the from Excel, it always asks for a password. I would like to remove the prompts / embed credentials so macro would run without any interruptions.
Thanks in advance!
AQuery is an Append Query that goes to ATable
Rich (BB code):
Dim db As ADODB.Connection
Dim cmd As New ADODB.Command
Dim dbPath As String
Dim AQuery As String
Dim ATable As String
Dim WS As Worksheet
ThisTemplate = ThisWorkbook.Name
dbPath = Range("G10")
AQuery = Range("G11")
ATable = Range("G12")
'RunQuery
Set db = New ADODB.Connection
db.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbPath & ";"
cmd.CommandType = adCmdStoredProc
cmd.CommandText = AQuery
cmd.ActiveConnection = db
db.Execute "DELETE * FROM " & ATable, FailonError
db.Execute AQuery, FailonError 'Macro stops here and asks for ODBC Oracle Driver Connect Credentials