title: Why Doesn't my SQL Server Database Connection Refresh via Excel VBA
body: <p>I have a report I am building from data I have in my SQL Server Database.
  I have 3 connections to the 3 different tables in the Database. </p>
  
  <p>I have 2 worksheets in my excel Report.</p>
  
  <pre><code>Sheet 1 = Report
  Sheet 2 = Data
  </code></pre>
  
  <p>I have the following simple macro to fire at the 'Workbook_Open' event:</p>
  
  <pre><code>Public Sub Refresh_Connection()
  
      'Wait for all Refresh Procedures to finish
      'This procedure will refresh the Connection to the database
      wsData.Activate
  
      Do Until Application.CalculationState = xlDone
          wsData.Activate
          ActiveWorkbook.RefreshAll
          ActiveWorkbook.Connections("KDSU513_JASONR dw_test Virtual_Bed_Board_Query_ChartData").refresh
          ActiveWorkbook.Connections("KDSU513_JASONR dw_test Virtual_Bed_Board_Query_SummaryData").refresh
          ActiveWorkbook.Connections("KDSU513_JASONR dw_test Virtual_Bed_Board_Query_AdmitData").refresh
  
          DoEvents
      Loop
      wsReport.Activate
  
  End Sub
  </code></pre>
  
  <p>Originally I was getting a message saying the Refresh wasn't complete so I had added a Wait similar to:</p>
  
  <pre><code>Application.Wait (Now + #12:00:15 AM#)
  </code></pre>
  
  <p>However I think this process stops everything from happening including the Database Refresh.  I feel like this should be so so simple but I'm missing something stupid.</p>
  
  <p>I have tried so many different methods but for some reason my Database Connection is not getting refreshed.</p>
  
  <p>Any assistance is greatly appreciated.
  Thanks in advance.</p>