Results 1 to 2 of 2
  1. #1
    Kody_Devl is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    22

    SQL Server Stored Procedure Output to MS Access Query

    Hi All,

    How can I get a SQL Server stored procedure output into an Access query so that I can Open the query and view the entire record(s) results?

    Here is the VBA that successfully runs the stored procedure. I can view the output in the intermediate window using:
    ?rs.Fields("Trust").value = -725.6

    This is what I want to see (whole record):
    Loan Number Trust Branch Processing Fee MIP ..........etc
    5660488444 -725.60 -1150.00 -1550.25

    Here is the code that I have so far.
    '*********************************
    Public Sub Run_HUD_Indvidual()
    '*********************************
    Dim cmdObj As New ADODB.Command
    Dim rs As New ADODB.Recordset
    Dim strLoanNo As String


    Dim SQL As String

    strLoanNo = "5660488444"

    cn_Dev.CommandTimeout = 15
    cn_Dev.Mode = adModeReadWrite
    Open_DEV ' Opens a Connection


    With cmdObj
    .ActiveConnection = cn_Dev
    .CommandType = adCmdStoredProc
    .CommandTimeout = 120
    .CommandText = "dbo.SUMMIT_AMB_HUD_Import_Revision_1_AutoImport_N etFunding_Individual_RWC"
    .Parameters.Append .CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue) ' Return should be first
    .Parameters.Append .CreateParameter("sLoanNumber", adVarChar, adParamInput, 50, strLoanNo)
    End With

    rs.CursorType = adOpenKeyset
    rs.LockType = adLockBatchOptimistic


    'Set rs = cmdObj.Execute

    rs.Open cmdObj

    'WORKS
    '? rs.Fields("MIP").Value
    '-725.6


    rs.Close
    Set rs = Nothing
    Set cmdObj = Nothing


    cn_Dev.Close
    Set cn_Dev = Nothing

    End Sub

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Why not bind a datasheet form to the recordset?
    https://docs.microsoft.com/en-us/off...et?source=docs

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-07-2018, 05:38 AM
  2. Stored Procedure in MS SQL Server from Access
    By jaryszek in forum Access
    Replies: 7
    Last Post: 01-17-2018, 05:58 AM
  3. Replies: 2
    Last Post: 06-01-2016, 08:52 AM
  4. Replies: 4
    Last Post: 01-03-2012, 08:11 PM
  5. Replies: 3
    Last Post: 05-23-2010, 05:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums