Here is how I would use it: Private Function Test ADODB() Dim rs as ADODB. Connection String = "Provider=SQLOLEDB; Data Source=Server SQLExpress,1433; Initial _ Catalog=My DB; User ID=johndoe; Password=password" . State = ad State Closed Then Msg Box "Can't open connection.", vb Information, "Error:" End If End With Set rs = New ADODB. Open My Recordset When I need to open a ADODB recordset in my code I use this procedure to connect, get my data, and then disconnect. Various databases may have a "Hard" id associated with each record, such as Oracle, or a data based ID such as an autoincrement ID field in MS ACCESS.The former is not part of the table definition as you create it, but is defined and maintained by the database engine, but can be accessed in SQL; the latter is defined by you when you create the table.This method is used to move to the last record in a Recordset object. Note: If you call Move Last() when the Recordset is empty, it generates an error.Note: An error will also occur if the Recordset object does not support bookmarks or backward cursor movement.To avoid the error we need to test if there is a record before using any of the Move methods by using these methods: Function Find Record Count(str SQL As String) As Long Dim db As Database Dim rst Records As Recordset Set db = Current Db Set rst Records = db. Code: Use this construct for looping through Access recordsets: Always test for No Match after using Seek or a Find method(Find First, Find Last, Find Next, Find Previous).
Close Set rst Records = Nothing Set db = Nothing End Function Note: Don’t Move Last unless you really need to: this will be slow with a large recordset or a recordset drawn across a network.We can reference the field to read or write a value to it by calling the Fields collection of the Recordset object.There are a number of ways to do this: Always close recordsets and set objects to Nothing in the error recovery of your procedure.If you need to open a full recordset that will allow you to add or edit data then you would use: Juan Soto is a Senior Access Developer at IT Impact Inc. He specializes in Access with SQL Server databases. Open “select * from issue_bk”, db, ad Open Keyset, ad Lock Optimistic If Not (txtlibid. His passion for Access has led him to helping a wide range of businesses in helping them establish a secure, stable and efficient environment with SQL Server.