give this a try
Sub Check()
Dim bOK as Boolean
On Error Resume Next
Do
dbConnectStr = "Provider=msdaora.1;" & _
"Data Source=YourDataSource;User Id=YourUserID; Password="
Connection.ConnectionString = dbConnectStr
Connection.Properties("Prompt") = adPromptAlways
Connection.Open dbConnectStr
Select Case Err.Number
Case Is = -2147217843
bOK = False
MsgBox "Incorrect credential", vbCritical, "Incorrect Credential"
Case Is = -2147217842
bOK = False
MsgBox "Operation Cancelled", vbInformation, "Operation Cancelled"
Exit Sub
Case Else
SQL = "SELECT blah from blah"
bOK = True
RecordSet.Open SQL, Connection
End Select
Err.Clear
Loop Until bOK
On Error GoTo 0
End Sub