Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-29
8
Medium Priority
?
447 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

636 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