Solved DAO tutorial reference (1 Viewer)

Mina Garas Daniel

Registered User.
Local time
Tomorrow, 00:03
Joined
Jul 21, 2017
Messages
66
Hi everyone
I notice most of my vba experience needs is around DAO

So can any body recommend websites or pdf files for DAO learning or tutorials

Thanks
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:03
Joined
Feb 19, 2002
Messages
43,484
The most complete reference out there is "DAO Object Model" by Helen Feddema. The fact that it was written in 2000 is irrelevant . I'm pretty sure nothing important has changed since then although replication is no longer supported. You won't find anything more detailed. I do have one criticism of the code samples though. None of the DAO objects are disambiguated. That means that if later you or someone else adds ADO code, there will be a conflict. It is always best whether you use DAO or ADO to ALWAYS disambiguate as you write the initial code rather than having to fix it later.

Dim db as DAO.Database
Dim qd as DAO.Querydef
Dim rs as DAO.Recordset
etc.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:03
Joined
Sep 12, 2006
Messages
15,710
I agree with Pat. It's one of my most used reference books.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:03
Joined
Feb 19, 2002
Messages
43,484
The sample that was hardest to find was one that used parameters in the query. Here is one example. When I write queries with parameters that I'm going to fill with values, I name them "enterSomeFieldName" so I don't have to open the query to figure out what the parametername is.
Code:
Public Function CountListItems() As Variant
    Dim db As DAO.Database
    Dim qd As DAO.QueryDef
    Dim rs As DAO.Recordset
   
On Error GoTo Err_Proc
    CountListItems = Null
    Set db = CurrentDb()
    Set qd = db.QueryDefs!qListValuesCount
        qd.Parameters!enterauditparmsid = [Forms]![frmLogin]![cboAuditParmsID]
        qd.Parameters!enterlistname = [Forms]![frmManageLists]![lstTableNames]
    Set rs = qd.OpenRecordset(dbOpenSnapshot)
    If rs.EOF Then
        MsgBox "no records found", vbOKOnly
        Exit Function
    End If
    CountListItems = Nz(rs!RecCount, 0)
Exit_Proc:
    Exit Function
Err_Proc:
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & "--" & Err.Description
            Resume Exit_Proc
    End Select
End Function
AccQueryWithParms.JPG
 

Users who are viewing this thread

Top Bottom