Store and Open File Paths in Access 2013 with VB.NET
Question details
Store paths to patient media files in an Access database and open the files later from a VB.NET text box.

- Product
- Microsoft Access 2013 and VB.NET
- Device & OS
- Windows
- Scenario
- A Windows application tracks videos, images, documents, and PDFs without storing the files themselves in the database.
- Observed behavior
- The application should save the complete file path, display it when the record is reopened, and launch the associated file on request.
Confirm that the files are stored in a location the application can access later, including from other computers if necessary. Check that users have permission to access the patient media files and that the Access field can accommodate paths up to 255 characters.
Save the Full Path in Access and Open It from VB.NET
Use a Short Text field to store a file path instead of storing the file as an Access attachment.
In Access, open the relevant table in Design View and add a Short Text field, such as FilePath. Set its Field Size to 255 and save the table. Use a separate record or related table if you need to store multiple paths for one patient.
In your VB.NET form, use OpenFileDialog to select a file and assign its complete path to the text box: If OpenFileDialog1.ShowDialog() = DialogResult.OK Then Me.TextBox1.Text = OpenFileDialog1.FileName. Replace TextBox1 with your control's name.
Save Me.TextBox1.Text to the FilePath field using your existing database insert or update code. Use an OleDbCommand with ? placeholders and parameters added in the same order as the placeholders. When loading the patient record, assign the stored FilePath value back to Me.TextBox1.Text.
In the Open button's Click handler, check System.IO.File.Exists(Me.TextBox1.Text), then call Process.Start(Me.TextBox1.Text). Handle a missing file or launch error by showing a message to the user. In modern .NET, use Process.Start(New ProcessStartInfo(Me.TextBox1.Text) With {.UseShellExecute = True}) to open the file with its default application.

Work with Linked Office Documents in WPS Office
WPS Office is a free, lightweight alternative for viewing and editing Office documents referenced by your application. Its familiar interface and format support make it easy to bring existing documents over. It does not replace Access or fix the VB.NET database code.

Frequently Asked Questions
Should I use an Attachment field to store the file path?
No. In Access table Design View, use a Short Text field for the path. An Attachment field is intended to store attached files rather than just their locations.
Why might a saved file path stop working?
The file may have been moved, renamed, or deleted, or the current user may lack access to its folder. Check the stored path with System.IO.File.Exists before attempting to open it.
Can another computer open a file using the stored path?
Yes, if the path points to a location that computer can reach and the user has permission. A local path such as C:\ may refer to a different location on another computer; an accessible network path may be more suitable.
What happens if a path is longer than the Access Short Text limit?
A Short Text field holds up to 255 characters. Shorten the folder or file name, or consider a Long Text field and adjust the application and database parameters to support longer values.




