+ Reply to Thread
Results 1 to 7 of 7

Userform 'not responding' while waiting for SQL query with ODBC

  1. #1
    Registered User
    Join Date
    11-29-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    9

    Userform 'not responding' while waiting for SQL query with ODBC

    I know the DoEvents function but I think its not solved my probelm in this case.

    I started an SQL query with ODBC connection in a Userform. While the excel wait for the database results until then the Userform is going to "not responding" mode.
    How can I get back the control on Userform while the SQL query is running and waiting for the results?

    ODBC connection:
    Please Login or Register  to view this content.
    Here is the command when the Userform go to "not responging" mode. The excel wait for the SQL database about 30 seconds.
    Please Login or Register  to view this content.
    After that the excel gets the SQL results and the Userform is active again and i have no problem. I can list the results with DoEvents etc.

    Can you help me?
    Sorry for my english.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Userform 'not responding' while waiting for SQL query with ODBC

    You require asynchronous connection:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-29-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Userform 'not responding' while waiting for SQL query with ODBC

    Okay, thank you its working but its create a new question:
    How can I know when finished the SQL query? Because the excel is running over and at the next command line (RC = SQL.RecordCount) I have an error message (I have that in hungary I tried to translate): "Run-time error: 3704 - The operation is not allowed if the object is closed". I wait about 30 seconds and then I click Debug button at this error message, press F5 to continue the macro running and works everything good.

  4. #4
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Userform 'not responding' while waiting for SQL query with ODBC

    You may use events. Change the declaration of SQL to the top of your code module like so:
    Please Login or Register  to view this content.
    and then you must move all of your code from after the SQL.Open line into an event:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-29-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Userform 'not responding' while waiting for SQL query with ODBC

    Thank you, I understand this method. I did it but the event is not working.
    I can read datas from the receordset in watch view but the "Private Sub SQL_FetchComplete" event is not working/starting.

    It is interesting because in an other sub I do the list of recordset with manual start and the "Private Sub SQL_RecordsetChangeComplete" event is working. The SQLDB_ConnectComplete event also working. But the FetchComplete or FetchProgress not.

    Why?
    Last edited by zeee1980; 11-29-2013 at 01:50 PM.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Userform 'not responding' while waiting for SQL query with ODBC

    There are some requirements you must adhere to - they are given in this Microsoft article: http://support.microsoft.com/kb/262311

  7. #7
    Registered User
    Join Date
    11-29-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Userform 'not responding' while waiting for SQL query with ODBC

    Problem solved with:

    Please Login or Register  to view this content.
    Thanks a lot.

+ 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] Why UserForm is “Not Responding” During Run Time in VBA Excel?
    By Timur Aykut YILDIRIM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 09:37 AM
  2. Userform: form controls stop responding - weird
    By madhg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2009, 12:23 PM
  3. [SOLVED] waiting Query result
    By Paolo9001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2006, 06:45 AM
  4. Waiting for data to be returned from Microsoft Query
    By bclakey in forum Excel General
    Replies: 0
    Last Post: 06-30-2005, 08:05 PM
  5. Waiting Mode when query data from Db via VBA!
    By Microlong in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2005, 10:06 AM

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