+ Reply to Thread
Results 1 to 4 of 4

how to close down a query

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    how to close down a query

    When I write the code for a query using adodb I can clear it after use by using something like
    Set Newrst = Nothing
    I have been working with Sage Line100 which does not seem happy with recordsets and have therefore used ODBC and Querytables instead.
    Can any one help me with shutting down such a query. Code such as
    Set Sageqt = nothing
    Although it does not cause an error, does not work so the number of named corrections grows as the application is used.
    What should I using to clear the query after it has been used

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: how to close down a query

    Can you post the code that's opening Sageqt?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: how to close down a query

    Norie, this is what I have been trying
    Sub DownLoad(SheetName, SQLStr)
    Sheets(SheetName).Visible = True
    Const SAGECONN1 As String = "ODBC;DSN=WindmillSage;UID=test;;"
    Dim qtSage As QueryTable
    Dim rngDest As Range
    
           Set rngDest = Sheets(SheetName).Range("A8")
            Set qtSage = Worksheets(SheetName).QueryTables.Add(SAGECONN1, rngDest, SQLStr)
              qtSage.RefreshStyle = xlOverwriteCells
              
              qtSage.Refresh False
              Set qtSage = Nothing
              
              Set rngDest = Nothing
    'ActiveWorkbook.Connections("Connection").Delete
    
    End Sub

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: how to close down a query

    That's a QueryTable you have, if you wanted to get rid of it I think you would have to delete it.

    Mind you that would mean losing the data, the connection etc.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel userform textBox pass SQl query and fetch data from close workbook
    By xlhelp7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-24-2016, 03:00 AM
  2. [SOLVED] Issue with Open, copy, close Macro - when trying to close workbook Clipboard error
    By seanpcorbett1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2016, 05:14 PM
  3. Using userform fetch data from close workbook using SQL Query
    By xlhelp7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2016, 01:06 AM
  4. [SOLVED] difference Close and Nothing in query
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2006, 06:55 AM
  5. [SOLVED] save & close after web query refresh
    By JVLin in forum Excel General
    Replies: 0
    Last Post: 09-28-2005, 12:05 PM
  6. Auto Open file VBA Refresh MS Query Save Close
    By gcutter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2005, 11:05 AM
  7. [SOLVED] Excel shoud not close all active books when clicking close button
    By technomike in forum Excel General
    Replies: 0
    Last Post: 06-10-2005, 01:05 PM

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