Solved

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

Posted on 2004-04-29
8
395 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:jaimexctsg
Comment Utility
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 8

Accepted Solution

by:
Mourdekai earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the points!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DoCmd.SetWarnings False is not working 9 31
Splitting out Data 14 27
Concatenating data within ACCESS table 3 19
Access MDB/PDF 21 28
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now