Public Function conn() As Boolean Set cn = New Connection On Error GoTo cnerr Dim connect As Boolean cn.ConnectionString = "PROVIDER=SQLOLEDB;DATA SOURCE=AIMIN;UID=sa;PWD=11111;DATABASE=Pratice" cn.ConnectionTimeout = 20 cn.Open conn = True Exit Function cnerr: conn = False MsgBox Err.Description End Function