Sub StartConnection()
    ' Declare a connection and error object
    Dim cnStateUBookstore As Connection
    Dim adoErr As Error

    Set cnStateUBookstore = New Connection

    ' Enable the error trap
    On Error Goto StartConnection_Handler

    ' Establish a connection to the data source
    With cnStateUBookstore
        .Provider = "SQLOLEDB"
        .ConnectionString = "User ID=sa;" & _
                            "Data Source=MSERIES1;" & _
                            "Initial Catalog=StateUBookstore"
        .Open
    End With

    ' If the connection succeeds, exit the procedure
Exit Sub

StartConnection_Handler:
    ' If an error occurs, loop through the collection
    ' There can be more than one error code for a single
    ' Run time error
    For Each adoErr in cnStateUBookstore.Errors
        ' Show each error description to the user
        MsgBox adoErr.Description
    Next
End Sub