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:
Sub UsingSQLOpen() Dim Chan As Variant Dim DataDate As String DataDate = Range("sheet2!B3") Chan = SQLOpen("DSN=SMP_DB;UID=sa;PWD=suprsonic") SQLExecQuery Chan, "SELECT * FROM InventoryTotalsHistory Where " & _ "ith_dtBusinessDate Between " & DataDate & "" SQLRetrieve Chan, Range("sheet2!D2") SQLClose Chan Chan = SQLOpen("DSN=SMP_DB;UID=sa;PWD=suprsonic") SQLExecQuery Chan, "SELECT * FROM InventoryFoodCostHistory Where " & _ "ifc_dtBusinessDate Between " & DataDate & "" SQLRetrieve Chan, Range("sheet2!AD2") SQLClose Chan End Sub




Reply With Quote