Results 1 to 6 of 6

Thread: VBA SQL Query shuts down Excel

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    34

    VBA SQL Query shuts down Excel

    Have the following code. When I run this the first query works and the second one shuts down Excel. When I step into this, it does it's dirty deed on the SQLExecQuery line.

    Any ideas out there?

    Dean

    VB Code:
    1. Sub UsingSQLOpen()
    2.  
    3. Dim Chan As Variant
    4. Dim DataDate As String
    5. DataDate = Range("sheet2!B3")
    6.     Chan = SQLOpen("DSN=SMP_DB;UID=sa;PWD=suprsonic")
    7.     SQLExecQuery Chan, "SELECT * FROM InventoryTotalsHistory Where " & _
    8.                     "ith_dtBusinessDate Between " & DataDate & ""
    9.     SQLRetrieve Chan, Range("sheet2!D2")
    10.     SQLClose Chan
    11.    
    12.     Chan = SQLOpen("DSN=SMP_DB;UID=sa;PWD=suprsonic")
    13.     SQLExecQuery Chan, "SELECT * FROM InventoryFoodCostHistory Where " & _
    14.                     "ifc_dtBusinessDate Between " & DataDate & ""
    15.     SQLRetrieve Chan, Range("sheet2!AD2")
    16.     SQLClose Chan
    17. End Sub
    Last edited by RobDog888; May 22nd, 2006 at 03:40 PM. Reason: Added [vbcode] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width