View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default stop macro if no SQL connection found

Good to know - thanks.

Tim


"NickHK" wrote in message
...
As the OP is using the default value (True) of the Options argument to
.Open, the connection is opened synchronously, so this works.

However, the .State is actually a bit mask so you should check the .State
with

If (cnn1.State And adStateOpen) = adStateOpen Then
'Connection is open
Else
'Connection is closed
End If

Read the help on the State Property, although the examples do not make
this
clear.
This was recently pointed out in:
http://groups.google.co.uk/group/mic...73fcb85898b202

NickHK