Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Opening a Recordset Based on a Table or Query

Sub OpenRst_TableOrQuery()     Dim conn As ADODB.Connection     Dim rst As ADODB.Recordset          Set conn = CurrentProject.Connection     Set rst = New ADODB.Recordset          rst.Open "Employees", conn          Debug.Print "CursorType: " & rst.CursorType & vbCr & "LockType: " & rst.LockType & vbCr _     & "Cursor Location: " & rst.CursorLocation          Do Until rst.EOF     Debug.Print rst.Fields(1)     rst.MoveNext     Loop     rst.Close     Set rst = Nothing     conn.Close     Set conn = Nothing End Sub