• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 450
  • Last Modified:

How to make sure that my Access 2000 mdb will reference DAO 3.6

I need to make sure that my Access 2000 mdb will reference DAO 3.6 wherever it is.
Here is the scenario:
I create an mdb, lets call it original.mdb. It need a reference to "Microsoft DAO 3.6". I go to the modules, open one of them, go to references, add the reference, and compile the whole thing. Now my original.mdb has a reference to "Microsoft DAO 3.6". So far so good.

Next, I create a new.mdb and import everything from the original.mdb. The problem is that now, my new.mdb does not have the references to "Microsoft DAO 3.6".

What can I do to make sure I will always have that reference wherever and whenever I impoort the objects from the original mdb?  Is this possible?

Thanks to all in advance.
0
jaimexctsg
Asked:
jaimexctsg
  • 3
  • 3
  • 2
1 Solution
 
rockiroadsCommented:
you could always use the VBA code which refreshes references, give that a try

Public Sub Install_RefreshReferences()
   
    Dim loRef As Object
    Dim iNoOfRefs As Integer
    Dim iCnt As Integer
    Dim bIsBroke As Boolean
    Dim strPath As String
    Dim bBroke As Boolean
   
    On Error Resume Next
   
   
    Err.Clear

    'Count the number of references in the database
    iNoOfRefs = Application.VBE.ActiveVBProject.References.Count
   
    'Loop through each reference in the database and determine if the reference is broken.
    'If it is broken, remove the Reference and add it back.
    For iCnt = iNoOfRefs To 1 Step -1
       
        Set loRef = Application.VBE.ActiveVBProject.References(iCnt)
        Debug.Print loRef.Name, loRef.FullPath
       
        'Dont do Application.VBE.ActiveVBProject.References
        With loRef
           
            bIsBroke = .IsBroken
            If bIsBroke = True Or Err <> 0 Then
               
                Err.Clear
                strPath = .FullPath
                Debug.Print strPath
               
                With Application.VBE.ActiveVBProject.References
                    .Remove loRef
                    If Err.Number > 0 Then
                        If Err.Number <> 57101 Then  'Cant remove default reference
                            Debug.Print "Removal Failure (" & Err.Number & ") : " & Err.Description
                            MsgBox "Reference Removal Failure (" & Err.Number & ") : " & Err.Description, vbCritical, "Refresh Refs"
                        End If
                        Err.Clear
                    Else
                        .AddFromFile strPath
                        If Err.Number > 0 Then
                            Debug.Print "Insert Failure (" & Err.Number & ") : " & Err.Description
                            MsgBox "Reference Insert Failure (" & Err.Number & ") : " & Err.Description, vbCritical, "Refresh Refs"
                        End If
                        Err.Clear
                    End If
                End With
            End If
        End With
    Next
   
    Set loRef = Nothing
   
    Exit Sub
   
rrError:
    MsgBox "Error " & Err.Number & " trapped." & vbCrLf & Err.Description, vbCritical, "Refresh Refs"
End Sub
0
 
MourdekaiCommented:
Here's a function I wrote for another question similar to this, maybe it can help:

Call this function, if it (DAO 3.6) is broke it will fix it, it is already there it does nothing, and if it is missing it will add it.

Function CheckDAO()
On Error Resume Next
   Dim refItem As Reference
   Dim blnLoaded As Boolean

   blnLoaded = False
   For Each refItem In References
       If refItem.Guid = "{00025E01-0000-0000-C000-000000000046}" Then
           'The refItem is DAO
           If refItem.IsBroken Then
               With Access.References
                   Debug.Print "DAO 3.6 is broken"
                   'remove it
                   .Remove refItem
                   'add it back
                   .AddFromGuid "{00025E01-0000-0000-C000-000000000046}", 5, 0
                   blnLoaded = True
               End With
           Else
               Debug.Print "DAO 3.6 Already loaded"
               blnLoaded = True
           End If
       End If
   Next refItem
   
   If blnLoaded = False Then
       Debug.Print "DAO 3.6 wasn't there so we added it"
       'It wasn't there, so we add it now
       Access.References.AddFromGuid "{00025E01-0000-0000-C000-000000000046}", 5, 0
   End If

End Function
0
 
jaimexctsgAuthor Commented:
I will try both, but I am more inclined to use Mourdekai 's code.m The problem is that this will be distributed and I want to make sure the client does not get an error message fron Access, since he wont have the tools to fix it.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
jaimexctsgAuthor Commented:
Sorry to look so dumb, but I could not get it to work. If my mdb does not have the reference to DAO, i cannot start it. I receive a compiler error: "user-defined type not defined".
i need this DAO360.dll to be referenced by the mdb, from code, no matter what. i could even include it in the distribution package, because it goes as an Access 2000 RT application.
Is it possible from code to make the reference happen?
Thanks again
0
 
MourdekaiCommented:
For my function you just need to call it from code.  You can even run it from the immediate window by just typing in:

CheckDAO

then hit enter.

0
 
rockiroadsCommented:
both sets of code need to be run in code

mine is slighly different, it checks ALL missing references and corrects them

Actually, Ive realised Ive given you the wrong one, I have two, one for Excel and one for Access, Excel works slightly differently, sorry about that

here is the access one, pass in TRUE to refresh all, FALSE to refresh broken refs only


Public Sub Install_RefreshReferences(Optional ByVal bByPassBroke As Boolean = False)
   
    Dim loRef As Access.Reference
    Dim intCount As Integer
    Dim intX As Integer
    Dim blnBroke As Boolean
    Dim strPath As String
    Dim bBroke As Boolean
   
    'on error resume next
   
   
    Err.clear

    'Count the number of references in the database
    intCount = Access.References.Count
   
    'Loop through each reference in the database and determine if the reference is broken.
    'If it is broken, remove the Reference and add it back.
    For intX = intCount To 1 Step -1
       
        Set loRef = Access.References(intX)
        Debug.Print loRef.Name, loRef.FullPath
       
        'Dont do Access
        With loRef
           
            If bByPassBroke = False Then
                blnBroke = .IsBroken
                If blnBroke = True Or Err <> 0 Then
                    bBroke = True
                Else
                    bBroke = False
                End If
            Else
                bBroke = True
            End If
           
            If bBroke = True Then
                Err.clear
                strPath = .FullPath
                With Access.References
                    .Remove loRef
                    If Err.Number > 0 Then
                        If Err.Number <> 57101 Then  'Cant remove default reference
                            Debug.Print "Removal Failure (" & Err.Number & ") : " & Err.Description
                            MsgBox "Reference Removal Failure (" & Err.Number & ") : " & Err.Description, vbCritical, "Refresh Refs"
                        End If
                        Err.clear
                    Else
                        .AddFromFile strPath
                        If Err.Number > 0 Then
                            Debug.Print "Insert Failure (" & Err.Number & ") : " & Err.Description
                            MsgBox "Reference Insert Failure (" & Err.Number & ") : " & Err.Description, vbCritical, "Refresh Refs"
                        End If
                        Err.clear
                    End If
                End With
            End If
        End With
    Next
   
    Set loRef = Nothing
   
    MsgBox "References have been refreshed", vbInformation, APP_TITLE
    Err.clear
   
    Exit Sub
   
rrError:
    MsgBox "Error " & Err.Number & " trapped." & vbCrLf & Err.Description, vbCritical, APP_TITLE
End Sub

0
 
jaimexctsgAuthor Commented:
Sorry I haven't answered yet, I got mixed up with about four diferent security.mdw's for about seventeen diferent mdb's. Even though I know all the passwords it is a mess in here. Will get back to you as soon as I can .
0
 
MourdekaiCommented:
Thanks for the points!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now