File Sharing Problems

How to Replace Mapped Drive Paths with UNC Paths in Access VBA

Chanuka GeekiyanageChanuka Geekiyanage Nov 3, 2026 869 views

Question details

The user needs to convert mapped drive paths (e.g., Z:\) to standard UNC paths in an Access VBA form so that all team members can access linked files.

How to Replace Mapped Drive Paths with UNC Paths in Access VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
Multiple team members are using a shared Access database, but hardcoded mapped drive letters prevent others from opening linked files if their drive mappings differ.
Observed behavior
File paths rely on specific mapped drive letters, creating a dependency that breaks file access for users who map the same network location to a different letter.
Before you start

Verify the exact UNC path (e.g., \\ServerName\ShareName) of your network drive and ensure you have administrative access to modify the VBA code and tables in your Access database.

Solution 1Recommended

Use VBA to Combine Relative Paths with a Configurable UNC Root

This method replaces hardcoded mapped drive paths by storing only the relative file path and combining it dynamically with a shared UNC root path using a VBA AfterUpdate event.

Instead of saving drive-specific paths directly in your tables, it is best practice to store a relative file path or folder name. By defining a global UNC root, you ensure that the linked files will resolve correctly for all users regardless of their local drive mappings.

1
Define the UNC Root Variable

Open the VBA editor in Access and define a public constant or system-level variable for your shared UNC root folder (e.g., Public Const UNCRoot As String = "\\FS2\BidControl\").

2
Update Table Records

Modify the records in your database table to store only the relative folder or file name (e.g., "250950") instead of the full mapped path (e.g., "Z:\250950").

3
Configure the AfterUpdate Event

In your form's design view, open the properties for the relevant control and add an AfterUpdate event procedure. Use VBA to concatenate the UNC root with the relative path: strFullPath = UNCRoot & Me.RelativePathField.

4
Test Network Access

Execute the form action to open the file. Verify that the combined UNC path resolves correctly over the network, allowing access without utilizing local mapped drive letters.

Use VBA to Combine Relative Paths with a Configurable UNC Root
Future-Proofing Your Database: By utilizing a variable for the UNC root, you can easily migrate your backend to a new server in the future simply by updating the UNCRoot variable string in one place.
Free Microsoft Office alternative

Manage Your Data with WPS Office as a Free Office Alternative

While Microsoft Access is built for complex database management and VBA scripting, WPS Office provides a free, lightweight, and highly compatible alternative for everyday office tasks. With powerful Spreadsheet capabilities, you can efficiently track data, run calculations, and share files across your team without worrying about complex path configurations.

  1. 1. Download and Install: Visit the official WPS Office website to download the free application and complete the installation on your device.
  2. 2. Open Data Files: Launch WPS Spreadsheet and easily open your exported .csv or .xlsx database files.
  3. 3. Collaborate Effortlessly: Use WPS Cloud to share links with your team, entirely bypassing the need to manage local UNC paths or mapped drives.
Highly compatible with Microsoft Excel formats (.xlsx, .xls, .csv) for flat-file database tracking.Free and lightweight suite offering Spreadsheet, Writer, Presentation, and PDF tools.Familiar tabbed user interface ensures a seamless migration with zero learning curve.Built-in cloud sharing features that eliminate the need for complex local network drive mappings.
microsoft office alternative - wps office

Frequently Asked Questions

What is the primary difference between a mapped drive path and a UNC path?

A mapped drive path uses a local letter (like Z:\) assigned to a network location, which can vary from user to user. A UNC (Universal Naming Convention) path uses the format \\ServerName\ShareName and remains consistent for all users connected to the same network.

Can I bulk convert existing mapped drive paths to UNC paths in my Access table?

Yes, you can run an Update Query in Microsoft Access utilizing the Replace() function. This allows you to automatically locate the mapped drive prefix (e.g., 'Z:\') and replace it with your universal network path across all existing records.

Why do some users still receive a 'Path not found' error after switching to UNC paths?

This error generally occurs if the user lacks the required network permissions to access the specified shared folder, or if the server name is not resolvable from their current connection (for example, if they are working remotely and not connected to the company VPN).