Others

Find the Main Database File Path from an Access Updater

Maira MehtabMaira Mehtab Nov 25, 2026 868 views

Question details

Find the path to a separate Main database from an Access updater database.

Find the Main Database File Path from an Access Updater
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

Open the updater database in Access, press Alt+F11, and choose Insert > Module.

2
Add the path function

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

3
Test the selection

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.

4
Use the saved path

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.

Verify the selected database: The function checks that the saved file exists, but it does not verify that it is the correct Main database or contains Clients. Validate those conditions before inserting a record.
Free Microsoft Office alternative

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.

Work with client lists in spreadsheets when a database is not requiredOpen and edit compatible Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface for common office tasksKeep document and spreadsheet work in one lightweight suite
microsoft office alternative - wps office

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.