-
execute cmd in DAO.
how do you execute a command using DAO?
basically, i want to be able to run a query, or insert, etc... and i am using DAO.
i know how to do it with ADO, but with DAO, i the books that i have only show me how to access recordsets, and parse them, but not how to actually modify any tables.
thanks,
eddie.
-
Newly created access 2000/2002 databases do not include the DAO 3.6 VB reference. Add the DAO reference using Tools, References when in the VBA editor, either while in your form's class module or a regular module under Modules.
I created a table called tblEntity with 3 records, then built a query using MS Access query builder to return all rows except where the ID was 2. Lame but who cares. I could have done an action query too (Update/Append/Delete etc.).
Sub DAOexample()
'Assumes you've added DAO 3.x object library to your list of references.
'This example used DAO 3.6 with MS Access 2000 for use in an .mdb file
'To avoid confusion between ADO and DAO, which can co-exist within the
'same project, we always fully qualify the object references.
'We are also using the default database connection rather than creating
'an independent DAO.Connection object, and the OpenRecordset command
'is using the default recordset type (because I did not specify).
Dim MyRecordset As DAO.Recordset
Set MyRecordset = CurrentDb.OpenRecordset("QryExampleMSAccessQueryDe f")
'See if any rows were returned:
If MyRecordset.BOF = False And MyRecordset.EOF = False Then
'Yes.
MyRecordset.MoveFirst
Do While MyRecordset.EOF = False
Debug.Print MyRecordset!EntityName
MyRecordset.MoveNext
Loop
End If
MyRecordset.Close
Set MyRecordset = Nothing
End Sub
-
i was actually able to include the appropriate ADO references after all, so i was able to go that route.
thanks.
-eddie.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|