Results 1 to 7 of 7
  1. #1
    mks123's Avatar
    mks123 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    33

    how to call stored Query

    Hello,



    Is there anyway to call query which in stored in MS Access through Excel?.

    any small help would be appreciated.
    Thanx in Advance.

    eg:"Query5" saved in CustomerDB.accdb

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Did you try Data > Get External Data from Excel ribbon?

    Do you want to use VBA in Excel to connect to Access?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mks123's Avatar
    mks123 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    33
    Yes VBA code.
    I know how to build SQL query
    but not sure about how to call stored query in ms access (which already created in Ms Access).

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I didn't ask if you know how to build SQL query. I asked if you tried the import wizard in Excel.

    Here is example of opening a recordset of Access data with VBA in Excel:
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset

    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset

    cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; Data Source='\\dotatufs02\CRM\Lab\Database\Data\LabData .accdb'"
    rs.Open "SELECT DISTINCT ProjectName FROM GeoDataAll;", cn, adOpenStatic, adLockReadOnly
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    mks123's Avatar
    mks123 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    33
    thanx for reply...

    this is all about how to creation of SQL query.
    But I am looking for how to call query which already created and stored in ms access.
    Because sometimes its hard and time consuming to create complex query for me.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    My question is why are you using Excel and Access? What is the problem/opportunity being solved -in simple plain English?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    As orange states, we need more info.

    So what is it exactly you want to do from Excel? Why is Excel involved? What bearing does 'calling' a saved query in Access have to do with "hard and time consuming to create complex query"? You said you know how to build SQL query.

    I already gave you two options for 'calling' a saved Access query object.

    1. Excel import wizard

    2. VBA in Excel that opens recordset object
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-14-2014, 03:56 PM
  2. Replies: 4
    Last Post: 01-03-2012, 08:11 PM
  3. Use VBA to call stored SQL from table
    By hcruz in forum Programming
    Replies: 2
    Last Post: 05-02-2011, 08:26 AM
  4. Help Writing VBA and call to query
    By brianb in forum Programming
    Replies: 7
    Last Post: 03-09-2011, 09:42 AM
  5. Calling Stored Proc in MS Access 2007 without creating query?
    By DistillingAccess in forum Programming
    Replies: 1
    Last Post: 08-03-2010, 09:38 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