Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone have any ADO examples

Status
Not open for further replies.
Sep 5, 2003
87
US
I was wondering if anyone had any basic ado examples of progammically opening a local Access table in the current database and moving thru it.

Thanks in advance.

MJ

 
Here is a quick example that you may find helpful:
Code:
Dim lRst_RecSet As ADODB.Recordset
Dim lStr_SQLStmt As String

Set lRst_RecSet = New ADODB.Recordset
lRst_RecSet.ActiveConnection = CurrentProject.Connection
lStr_SQLStmt = &quot;SELECT   <Field List> &quot; & _
               &quot;FROM     <Table Name> &quot; & _
               &quot;WHERE    <Field Name> = '&quot; & <String Value> & &quot;' &quot; & _
               &quot;ORDER BY <Field List>&quot;
lRst_RecSet.Open lStr_SQLStmt, , adOpenForwardOnly, adLockReadOnly
If (lRst_RecSet.State = adStateOpen) Then
   If ((lRst_RecSet.BOF = False) And (lRst_RecSet.EOF = False)) Then
      lRst_RecSet.MoveFirst
      Do While (lRst_RecSet.EOF = False)
         <Process The Record>
         lRst_RecSet.MoveNext
      Loop
   End If
   lRst_RecSet.Close
End If
Set lRst_RecSet = Nothing


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top