Find the Main Database File Path from an Access Updater
Question details
Find the path to a separate Main database from an Access updater database.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- An updater needs to locate the user's Main database before inserting a client record into its Clients table.
- Observed behavior
- CurrentProject.Path returns the folder of the open updater database, not the location of the separate Main database.
Identify the Main database file and confirm that it contains the expected Clients table. Check whether the updater has a table linked to Main; if it does not, select and save the path during setup.
Select and save the Main database path
Use a file picker when there are no linked tables, then save the selected path for later updater sessions.
The following VBA example stores the full file path in the current user's Windows registry. If the saved file no longer exists, it prompts the user to select it again.
Open the updater database in Access, press Alt+F11, and choose Insert > Module.
Paste this code into the module: Public Function MainDatabasePath() As String Dim savedPath As String Dim picker As Object savedPath = GetSetting("MyUpdater", "Settings", "MainPath", "") If Len(savedPath) > 0 Then If Len(Dir(savedPath)) > 0 Then MainDatabasePath = savedPath Exit Function End If End If Set picker = Application.FileDialog(3) With picker .Title = "Select the Main database" .AllowMultiSelect = False .Filters.Clear .Filters.Add "Access databases", "*.accdb;*.mdb" If .Show = -1 Then savedPath = .SelectedItems(1) SaveSetting "MyUpdater", "Settings", "MainPath", savedPath MainDatabasePath = savedPath End If End With End Function
In the VBA editor, open View > Immediate Window and enter ? MainDatabasePath(). Select the Main database when the file picker appears; the full path is printed in the window.
Call MainDatabasePath() from the updater code before opening Main. If it returns an empty string because the user canceled, stop the update and prompt for a database instead.
Read the path from an Access linked table
Use this approach if the updater has a table linked to the Main Access database.
Use WPS Office for Everyday Office Files
WPS Office is a free, lightweight alternative with a familiar interface for working with Office documents and spreadsheets. Open compatible files to make migration straightforward. WPS Office does not locate or update Microsoft Access databases.

Frequently Asked Questions
Why doesn't CurrentProject.Path return the Main database location?
CurrentProject.Path returns the folder of the currently open Access project. When the updater is open, it returns the updater's folder, not the path of a separate Main database.
Can the updater find Main without a linked table?
Yes. Prompt the user with Application.FileDialog to select the database, then save its full path in a configuration file or with VBA's SaveSetting for future use.
How can I check a linked table's database path?
In the VBA Immediate Window, print CurrentDb.TableDefs("TableName").Connect, replacing TableName with the linked table's name. For an Access link, inspect the DATABASE= value.
What happens if the saved Main database file is moved?
The example checks the saved path with Dir. If the file is no longer there, it opens the file picker so the user can select the new location.




