+ Reply to Thread
Results 1 to 3 of 3

Check ODBC connection before refresh

  1. #1
    Registered User
    Join Date
    03-23-2005
    Posts
    33

    Question Check ODBC connection before refresh

    Hi

    I have an Excel spreadsheet linked through to a sql table via and ODBC connection and I have a macro to refresh the data. I want the macro to first check that the ODBC connection exists before trying to refresh the data. So it would look like:

    IF ODBC Connection exists THEN refresh data ELSE return warning message.

    becoz when connection cannot be made, its gives me error. and i have to manually press ok button.


    Any ideas....?

    thanks

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Check ODBC connection before refresh

    I fear you do not want to check whether a connection exists or not or but whether the connection can be established or not. You can only check that by connecting.... and then you are back to what you want to avoid.
    Why would the connection fail, once it worked ?

    You can always check for errors (and suppress error messages) with

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-23-2005
    Posts
    33

    Unhappy Re: Check ODBC connection before refresh

    ok,
    file is on client pc and its trying to get data from mqsql server on other computer.

    Sometimes that server goes down for maintenance.

    File on client pc auto refresh data every 2 mins.
    so during auto refresh if server is down and then excel cannot auto refresh the data, so it gives error and macro stop working.

    i have to press debug button every time when it cannot connect to database to refresh the data. which i want to avoid.

    thanx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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