Solved

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

Posted on 2004-04-29
8
435 Views
Last Modified: 2008-03-06
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
Comment
Question by:jaimexctsg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10953740
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
 
LVL 8

Expert Comment

by:Mourdekai
ID: 10953784
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
 

Author Comment

by:jaimexctsg
ID: 10954599
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:jaimexctsg
ID: 10955124
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
 
LVL 8

Accepted Solution

by:
Mourdekai earned 500 total points
ID: 10956080
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 10956287
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
 

Author Comment

by:jaimexctsg
ID: 10957048
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
 
LVL 8

Expert Comment

by:Mourdekai
ID: 10960658
Thanks for the points!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question