Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004

    Unanswered: How to Output SQL Server SP result to xls file?

    Hi all!
    In a project I'm working on I need to import a result of SQL Server Stored Procedure (a simple Select-Union sql-statement) to xls file.
    In code (below) I'm establishing connection to SQL Server and than trying to have sp_ActiveAccounts Stored Procedure outputting in xls file. The window "Output To" pops up. When I click OK I got an error message: "The MS Jet Engine cannot 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=Mi crosoft® Windows® Operating System;WSID=test PC;DATABASE=" & strDBName, "LoginName", "password"

    DoCmd.OutputTo acOutputStoredProcedure, "sp_ActiveAccounts", "MicrosoftExcelBiff5(*.xls)", "", False, "", 0

    thank you all in advance

  2. #2
    Join Date
    Mar 2004
    Never mind.
    I've created Pass Through Query that do the job perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts