Code: Easy ADODB Note: this code is part of a blog post I created, for more information, including samples of how to use the code in Access, please click to view the post: http://accessexperts.net/blog/2011/01/21/easy-adodb-recordsets-and-commands-in-access/ Option Compare Database Option Explicit Global con As New ADODB.Connection Global NoRecords As Boolean Public Enum rrCursorType rrOpenDynamic = adOpenDynamic rrOpenForwardOnly = adOpenForwardOnly rrOpenKeyset = adOpenKeyset rrOpenStatic = adOpenStatic End Enum Public Enum rrLockType rrLockOptimistic = adLockOptimistic rrLockReadOnly = adLockReadOnly End Enum Public Function OpenMyRecordset(rs As ADODB.Recordset, strSQL As String, Optional rrCursor As rrCursorType, Optional rrLock As rrLockType, Optional bolClientSide As Boolean) As ADODB.Recordset If con.State = adStateClosed Then con.ConnectionString = conConnection & "User ID =" & ReadGV("UserID", strText) & ";Password=" & ReadGV("Password", strText) con.Open End If Set rs = New ADODB.Recordset With rs .ActiveConnection = con If bolClientSide Then .CursorLocation = adUseClient Else .CursorLocation = adUseServer End If .CursorType = IIf((rrCursor = 0), adOpenStatic, rrCursor) .LockType = IIf((rrLock = 0), adLockReadOnly, rrLock) .Open strSQL If .EOF And .BOF Then NoRecords = True Exit Function End If End With End Function Public Function ExecuteMyCommand(strSQL As String) As Boolean Dim Comm As ADODB.Command On Error GoTo ErrorHandler Dim lngRecordsAffected As Long If con.State = adStateClosed Then con.ConnectionString = conConnection & "User ID =" & ReadGV("UserID", strText) & ";Password=" & ReadGV("Password", strText) con.Open End If Set Comm = New ADODB.Command With Comm .ActiveConnection = con .CommandText = strSQL .Execute lngRecordsAffected 'Debug.Print lngRecordsAffected End With ExecuteMyCommand = True ExitProcedure: 'Set Comm = Nothing Exit Function ErrorHandler: MsgBox Err.Description, vbCritical, "Error:" GoTo ExitProcedure End Function Public Function conConnection() As String If ReadGV("UseITImpactServer", logLogical) Then conConnection = ReadGV("ConnectionITImpact", strText) Else conConnection = ReadGV("ConnectionClient", strText) End If End Function