In a project I'm working on I need to import a result of SQL Server View (Select-Union All sql-statement) or SQL Server Stored Procedure (the same sql-statement; I'm not sure if I get any benefits having select statement implementing as Stored Procedure, rather then simple View; perhaps there is no benefits in it) to xls document.
In code (below) I established connection to SQLServer and than trying to have sp_ActiveAccounts outputting in xls file. the window Output To pops up. When I click OK I got an error message: "The MS Jet Engine can not find the object sp_ActiveAccounts". I understand that DoCmd.OutputTo looks for Access database Tables/Queries, and that Jet Engine is active. How can I make it looking for Server's sp_ActiveAccounts Stored Procedure? What part of code have i omitted?
My code:
dim Cnxn As ADODB.Connection
Set Cnxn = New ADODB.Connection
Cnxn.Open "DRIVER={SQL Server};SERVER=ServerName;UID=AccessAccount;APP=Microsoft® Windows® Operating System;WSID=test PC;DATABASE=" & strDBName, "LoginName", "password"
DoCmd.OutputTo acOutputStoredProcedure, "sp_ActiveAccounts", "MicrosoftExcelBiff5(*.xls)", "", False, "", 0
thank you all in advance
In code (below) I established connection to SQLServer and than trying to have sp_ActiveAccounts outputting in xls file. the window Output To pops up. When I click OK I got an error message: "The MS Jet Engine can not find the object sp_ActiveAccounts". I understand that DoCmd.OutputTo looks for Access database Tables/Queries, and that Jet Engine is active. How can I make it looking for Server's sp_ActiveAccounts Stored Procedure? What part of code have i omitted?
My code:
dim Cnxn As ADODB.Connection
Set Cnxn = New ADODB.Connection
Cnxn.Open "DRIVER={SQL Server};SERVER=ServerName;UID=AccessAccount;APP=Microsoft® Windows® Operating System;WSID=test PC;DATABASE=" & strDBName, "LoginName", "password"
DoCmd.OutputTo acOutputStoredProcedure, "sp_ActiveAccounts", "MicrosoftExcelBiff5(*.xls)", "", False, "", 0
thank you all in advance
Last edited: