Question How to change default dir in Access 2007

RenaG

Registered User.
Local time
Yesterday, 17:47
Joined
Mar 29, 2011
Messages
166
Hi,

I have downloaded some sample files from the Microsoft Inside Out book. My employer does not allow us access to our c:\ so I had to put the db on my assigned network drive. When I open the db, I get messages about broken or missing references to dll files and then a message about VB libraries missing. When I get past those messages and try to open a table it comes up with an invalid path message showing that it is pointing to my c: (where the install would have put it if I had let it default to it). I have looked and looked and don't see a way to change the default path. Does anybody know how to do this?

TIA!
~RLG
 
Looks like you have a serious issue. Broken references are usually caused by two different office versions. One on which the database was created and one you are currently working on. You have to fix these first before continuing.

I assume that you are using a frontend and a backend. If the tables are linked to the backend and the backend was moved, simply richtclick on an attached table and select Linked Table Manager.

Or use the code below to automate this process:
Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Function RefreshLinkedTables() As Long
'Reattach linked tables according to setting in config.ini
'Contents Config.ini file:
'[System]
'Database = "D:\Work\ApplicationName\BE_DATA\Application_BE.mdb"

    Dim tdef As TableDef, sLink As String, sOldLink As String
    Dim strPath As String
    
    On Error GoTo Err_RefreshLinkedTables

    strPath = GetFromConfig("System", "Database", vbNullString)
    If strPath = vbNullString Then
        MyMsgBox "Configuration file doesn't exist or is invalid.", vbExclamation
    Else
        For Each tdef In DBEngine(0)(0).TableDefs
            sOldLink = tdef.Connect
            If Len(sOldLink) > 0 Then 'Table is linked
                If InStr(sOldLink, "database=") > 0 Then 'An attached table
                    If InStr(sOldLink, "Excel") = 0 Then 'Attached table is an Excel spreadsheet
                        sLink = ";DATABASE=" & strPath 'Create connection string
                        If sOldLink <> sLink Then ' different from original?
                            tdef.Connect = sLink 'Set new link
                            tdef.RefreshLink
                        End If
                    End If
                End If
            End If
        Next tdef
    End If
    
Exit_RefreshLinkedTables:
    Exit Function
    
Err_RefreshLinkedTables:
    If Err.Number = 3024 Then Resume Next  ' Couldn't find file
    
    MsgBox Err.Description
    RefreshLinkedTables = Err.Number
    GoTo Exit_RefreshLinkedTables
Resume
End Function
Public Function GetFromConfig(ByVal Section As String, ByVal Key As String, ByVal Default As String)
  GetFromConfig = GetKeyValueFromINI(StripPath(CurrentDb.name) & "\Config.ini", Section, Key, Default)
End Function

Public Function GetKeyValueFromINI(ByVal vstrIniFile As String, ByVal vstrSection As String, ByVal vstrKey As String, Optional ByVal vstrDefault As String) As String
    
  Dim lstrBuffer As String
  Dim llngRet As Long
  Dim lstrResult As String
  
  lstrBuffer = Space(255)
  llngRet = GetPrivateProfileString(vstrSection, vstrKey, "", lstrBuffer, Len(lstrBuffer), vstrIniFile)
  If llngRet <> 0 Then
    lstrResult = TrimNull(lstrBuffer)
  Else
    lstrResult = vstrDefault
  End If
  GetKeyValueFromINI = lstrResult

End Function

Public Function StripPath(strFilename As String) As String
'Return path without filename
'Getpart at http://www.access-programmers.co.uk/forums/showthread.php?t=175633&highlight=getpart
   Dim intX As Integer
   Dim intMax As Integer
   Dim strResult As String
   
   intMax = GetParts(strFilename, "\")
   
   strResult = ""
   For intX = 1 To intMax - 1
      strResult = strResult & GetPart(strFilename, "\", intX) & "\"
   Next intX
   
   StripPath = strResult

End Function

Share & Enjoy!
 
Hi Guus,

Thanks for your reply. I kinda thought that, based on the error message, that there were two different versions but I am running Access 2007 and these samples are from the Access 2007 Inside Out book so that just didn't make sense. I think the main problem is that there is a default set someplace that points to my c: (the folder that the install assumed was created and used). The actual messages I am getting are:
Your Microsoft Office Access 2007 Inside Out - Conrad Systems Contacts database or project contains a missing or broken reference to the file 'msadox.dll' version 6.0
*To ensure that your database or project works properly, you must fix this reference.

Press OK. Then another error message comes up:
One or more of the Visual Basic libraries required to run this sample database is missing. The most common cause is an older version of the Access Data Objects (ADO) libraries on your system. To be able to run this application, you must open any module, choose References from the Tools menu, and uncheck any libraries marked 'Missing'. You should attempt to find the equivalent library from the list of available libraries on your system and check it. (For example, this application uses ADO 2.7, but your system may have ADO 2.5 or earlier.) See also the Readme file on the companion CD.

When I did this, I did find the 'Missing' library and it is the one mentioned in the first message. But it is looking for files in the c: folder that would have been installed if I could do it like a normal person (instead of pointing it to another drive). I looked on my network drive and couldn't find any dlls in the folder I created for this install.

So it does finally open. But if I double click on a table it displays a message:
'C:\Microsoft Press\Access 2007 Inside Out\ContactsData.accdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

I right clicked on a table and selected the Linked Table Manager. Clicked on that one table in the explorer window, I selected the path and the db that the table belongs to and a message pops up that says:
The Microsoft Office Access databse engine cannot find the input table or query 'tblInvoices'. Make sure it exists and that its name is spelled correctly.

What a mess! I had hoped there was some place in Access that would let me override the default directory (maybe on the table level) but the only place I found to do that is in the Access Options under the Popular window and it does have the correct default path in the Default Database Folder.

One of my coworkers suggested that I request a VM so I could have an unrestricted playground to play in. I may have to go that route.

I hope you have a great day!

~RLG
 
Last edited:
It is strange that Access misses the most basic references. Did you fix them before continuing?

Did you reboot?
Did you restart Access?

If all that doesn't work, you might want to consider reinstalling Access...

HTH:D
 

Users who are viewing this thread

Back
Top Bottom