Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 21 of 21

Thread: Utilizing Stored procedure parameters in VBA

  1. #21
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Assuming:

    - a database G:\Access\fiets.mdb
    - a 'stored procedure' (= Query), name Q_test

    you can retrieve the data from this database, using the stored procedure 'Q_test', and put them in a table in sheet1, using:

    Sub M_snb()
        With Sheet1.ListObjects.Add(0, "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\Access\fiets.mdb", , , Range("$A$1")).QueryTable
            .CommandType = 3
            .CommandText = "Q_test"
            .Refresh False
        End With
    End Sub
    the same result using the Microsoft ActiveX Data Objects 2.0 Library:

    Sub Access_query_snb()
        ' Reference to Microsoft ActiveX Data Objects 2.0 Library
    
        With New Recordset
            .Open "SELECT * FROM Q_test", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Access\fiets.mdb"
            Sheet1.Cells(20, 1).CopyFromRecordset .DataSource
        End With
    End Sub
    Last edited by snb; 04-08-2014 at 01:07 AM.

Tags for this Thread

Posting Permissions

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