[AccessD] DAO References in New DBs

Gustav Brock Gustav at cactus.dk
Wed Sep 26 10:16:03 CDT 2007


Hi Mark

You can run a function to do this:

<code>

  ' Length of GUID string per definition.
  Private Const clngGUID                As Long = 38

  Type GuidDefinition
    Guid As String * clngGUID
    Major As Integer
    Minor As Integer
  End Type

Public Function RefAddDao() As Boolean

  Dim typGuid As GuidDefinition
  
  With typGuid
    .Guid = "{00025E01-0000-0000-C000-000000000046}"
  End With
  
  RefAddDao = ReferenceAddFromGuid(typGuid)
  
End Function

Public Function ReferenceAddFromGuid(ByRef typGuid As GuidDefinition) As Boolean

' Add a reference from its GUID and verify it.
'
' 2001-08-20. Cactus Data ApS, CPH.


  ' Reference Guid not registered or registered with a lower version.
  Const clngErrorGuidNotRegistered As Long = -2147319779
  
  Dim ref         As Reference
  
  Dim booSuccess  As Boolean
  
  On Error Resume Next
  
  With typGuid
    References.AddFromGuid .Guid, .Major, .Minor
  End With
  
  If Not Err = clngErrorGuidNotRegistered Then
    ' The reference is registered but it may have been tampered with.
    ' Find it and check that it is not broken.
    For Each ref In References
      With ref
        If .BuiltIn = True Then
          ' no need to study built in references.
        ElseIf .Guid = typGuid.Guid Then
          ' This is the added reference.
          booSuccess = Not IsBroken97(ref)
          If booSuccess = True Then
            ' Return actual GUID version.
            typGuid.Major = .Major
            typGuid.Minor = .Minor
          End If
        End If
      End With
    Next
  End If
  
  Set ref = Nothing
  
  ReferenceAddFromGuid = booSuccess

End Function

Public Function IsBroken97(ByVal ref As Access.Reference) As Boolean

' Alternative method to check if a reference is broken
' as the IsBroken property cannot be used in Access97.
'
' 2000-03-19. Gustav Brock. Cactus Data ApS.

' Refer to this article at Microsoft Technet:
'
' Article ID: Q186720
'
' The information in this article applies to:
' Microsoft Access 97
'
' SYMPTOMS
' In Microsoft Access, IsBroken is a property of the References collection.
' The Microsoft Access Help topic on the Isbroken property states the following:
'
' The IsBroken property returns a Boolean value indicating whether a
' Reference object points to a valid reference in the Windows Registry.
'
' Although this statement is correct, to receive this Boolean value
' you must trap for errors that are generated by the broken reference.
' Also, the IsBroken property becomes True only when the file being referenced
' is deleted and the Microsoft Windows Recycle Bin is emptied.
' This article details the steps necessary to receive the Boolean value.

  Dim booRefOK As Boolean
  On Error GoTo Err_IsBroken97
  
  If Len(Dir(ref.FullPath, vbNormal)) > 0 Then
    booRefOK = Not ref.IsBroken
  End If

Exit_IsBroken97:
  IsBroken97 = Not booRefOK
  Exit Function

Err_IsBroken97:
  ' Ignore non existing servers, drives, and paths.
  Resume Exit_IsBroken97
  
End Function

</code>

/gustav

>>> markamatte at hotmail.com 26-09-2007 17:05 >>>

Sorry I forgot to change the Subject...Any ideas on how to get around this...other than manually doing it everytime?


ORIGINAL QUESTION:
Hello All, 
I just converted a db to XP that used Ted Avery's front end updater. The  problem I am having is the temp db that is created does not have a DAO reference...actually any new db I create does not have a DAO reference. How can I set this in VBA? 
Thanks, 
Mark A. Matte






More information about the AccessD mailing list