In excel I created a class module to establish connection to the SQL server when file is opening. The weirdest thing is sometimes Excel will run the code below just fine and sometimes it won't recognize the connection or the connection reference. The fix is copy the code below and paste it back.
Does anyone ever experience anything like this before? Or does anyone has a solution or guidance for any fix?
Thanks!
J
Set cnn = New ADODB.Connection
With cnn
.CommandTimeout = 300 '5 minutes
.CursorLocation = adUseClient
.Open strConn
End With
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.Open strSQL, cnn, adOpenForwardOnly, adLockOptimistic, adCmdText
End With
Exit Function
Bookmarks