Results 1 to 3 of 3

Import Access Parameter Query to Excel

Threaded View

  1. #1
    Registered User
    Join Date
    04-12-2021
    Location
    West Monroe, LA
    MS-Off Ver
    Office 365
    Posts
    2

    Import Access Parameter Query to Excel

    Hello,
    I am wondering why my macro will not run. I am not skilled in Visual Basic. I am trying to import an Access parameter query into Excel. Any help would be appreciated.

    Access database name: "Steelfab Purchasing20210408"
    Query name is: "Spectrum Export Qry"
    Query parameter is "Enter PO"
    Excel sheet that I want the data to go to is called "DataDump"

    Following is the macro language.

    Sub AccParam() 'Excel VBA to import a parameter query from Access into Excel
        Dim MyDatabase As DAO.Database
        Dim MyQueryDef As DAO.QueryDef
        Dim MyRecordset As DAO.Recordset
    
        Set MyDatabase = DBEngine.OpenDatabase("E:\Steelfab Purchasing20210408.accdb")
        Set MyQueryDef = MyDatabase.QueryDefs("qrySpectrum Export Qry")
    
        Sheet1.[A2:R1100].DataDump.ClearContents 'Range to Clear
        MyQueryDef.Parameters("[Enter PO]") = DataDump.[a2].Value
        Set MyRecordset = MyQueryDef.OpenRecordset 'Open the query
        DataDump.Range("A11").CopyFromRecordset MyRecordset
    
    End Sub
    Last edited by AliGW; 04-12-2021 at 09:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. RUn Access Parameter Query From Within Excel
    By jo15765 in forum Excel General
    Replies: 3
    Last Post: 08-17-2016, 08:53 AM
  2. Import Access query results into Excel show import status
    By mwatson4788 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2016, 10:12 AM
  3. Import Access Query To Excel
    By dkannapel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 12-26-2013, 02:58 PM
  4. Import Query in Access to Excel
    By lehainam in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2008, 07:50 PM
  5. [SOLVED] access query to import to excel
    By jazzydwit in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-16-2006, 09:05 PM
  6. [SOLVED] Linking parameter query from Access to pivot table in Excel
    By ken1975 in forum Excel General
    Replies: 2
    Last Post: 06-20-2006, 08:55 AM
  7. import data from an Access parameter query
    By PluckyMo in forum Excel General
    Replies: 2
    Last Post: 04-11-2006, 11:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1