none
Can I Refresh All Acces Queries From Excel? RRS feed

  • Question

  • I found an easy way to list all queries in Access, from within Access.

    Set dB = Application.CurrentData
    For Each qry In db.AllQueries
    Debug.Print qry.Name
    Next qry
    
    strMsg = " -- Queries listing complete -- "
    
    Procedure_Done:
    dmwListAllQueries = strMsg
    Exit Function
    
    Error_Handler:
    strMsg = Err.Number & " " & Err.Description
    Resume Procedure_Done

    What I really want to do is refresh all select queries in Access, but I want to do this from within Excel.  I'm running other processes in Access, from within Excel, and I want to try to control everything from within my Excel environment, rather than switching back and forth between Excel and Access.


    MY BOOK

    Thursday, June 15, 2017 6:21 PM

All replies

  • Hi ryguy72,

    did you try to use code like below.

    if not you can have a try.

    Currentdb.TableDefs.Refresh

    you can try to open database from Excel and then try to refresh it.

    Sub  Example1()
    'Access object 
    Dim  appAccess As  Object 
    
    'create new access object 
    Set  appAccess = CreateObject("Access.Application")
    'open the acces project 
    Call  appAccess.OpenCurrentDatabase( _
    "D:StuffBusinessTempNewDB.accdb")
    appAccess.Visible = True
    appAccess.TableDefs.Refresh
    End  Sub 

    Reference:

    TableDefs.Refresh Method (DAO)

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 16, 2017 2:59 AM
    Moderator
  • Thanks!!

    MY BOOK

    Friday, June 16, 2017 7:11 PM
  • Hi ryguy72,

    is your issue solved?

    if it is solved now then I suggest to post the solution and mark it as an answer.

    so that we can close this thread.

    if your issue is still exist then let us know about that.

    we will try to provide further suggestions to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 29, 2017 8:25 AM
    Moderator