I have the following code in place to check for a connection to a database. It is supposed to do stuff on error instead of showing a cryptic error box. (run time error blah blah blah... can't connect to MySQL server on server .....
Right now, I get it to error by just unplugging my network cable, as I am connecting to a remote server. Instead of getting my message box and errors, it is spitting out the cryptic (to joe bloggs) error briefly described above when trying to run .open. Am I missing anything there?
Code:
Private Sub Form_Load()
Set cn = New ADODB.Connection
On Error GoTo connErr
With cn
If .State = 0 Then
.ConnectionString = DB_CONNECT
.Open
islocal = False
End If
End With
sub_exit:
Exit Sub
connErr:
MsgBox "Sorry, couldn't connect to database. Please try again later", vbOKOnly
Me.Contacts.Enabled = False
Me.OpenQuotes.Enabled = False
Me.OpDirectory.Enabled = False
Me.RepBtn.Enabled = False
Resume sub_exit
End Sub