473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to display the link to all selected files in a text box using FileDialog.AllowMul

Hello - I figured out how to code a button to browse windows explorer for files on a form in Access 2016. I opted to allow multi select because with shape files I will need to select several files. My button works, I can select multiple files, but only one shows up in the text box (named FileLocation) I created to display the link to the file. How can I display the links to all selected files on my access form?
All of these files are on shared drives. Is there a way to code to make the file name display after selecting it in Windows Explorer to do so that does not include the mapped drive letter but still link to the file? The problem is the shared drive is mapped with different letters on employee's individual computers. I need a file path to display, that whoever clicks on it will be able to open it in the shared drive regardless of what letter is used to map the shared drive.

Here is my code:

Private Sub Browse_File_Button_Click()

Dim f As Object
Dim strfile As String
Dim strfolder As String
Dim varItem As Variant

Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For Each varItem In f.SelectedItems
strfile = Dir(varItem)

strfolder = Left(varItem, Len(varItem) - Len(strfile))
MsgBox "Folder" & strfolder & vbCrLf & _
"File: " & strfile

FileLocation = strfolder & strfile
Next
End If
Set f = Nothing

End Sub

Thank you so much in advance for any assistance!
Mar 26 '20 #1
4 1493
ADezii
8,834 Expert 8TB
As each Selected File is processed, you can write the Folder and File Name to a Listbox with certain Properties set to simulate Hyperlinks. When you dbl-click on an entry in the Listbox, you can then use the FollowHyperlink Method of the Application Object to combine the Folder and File Path and Navigate to it. If you are interested, I'll post further details.

P.S. - See attachment for Listbox View of Files selected.
Attached Images
File Type: jpg Listbox.JPG (44.8 KB, 167 views)
Mar 26 '20 #2
Hi Adezii - Thank you much for taking the time to reply to my question. Researching an answer to my question, I have discovered I should possibly be using a listbox. My database is to track projects at work. We want to track any documents or data associated with each project. The idea is for people to go to a data form, click on a browse button to search Windows Explorer to where their file is located, have that file location stored in the database so that others can search on criteria to find data they need that others may have or to be able to compile all of the products produced for a project. I have the browser button working, I can select a file in Explorer, the file location is saved to a text box and saved to my database. The issue comes in with GIS data that usually involves multiple files to create one shape file. With this data, I need to be able to select 8 or so files at one time (which I have done with my browser button), and I have now directed those multiple files to a listbox, however I have discovered the file names are not saved in that listbox for that record in the database. My main goal is for people to be able to search for files, select them, have the file path information saved in a field in my database where the data can be queried by others to find data they need. My issue is how to save the data that has multiple files? I hope this is understandable and not too confusing. Thanks for any direction!
Mar 26 '20 #3
ADezii
8,834 Expert 8TB
Let's take things one step at a time. Take a look at the Attached Demo and see if it is, at least initially, what you are looking for.
Attached Files
File Type: zip Listbox.zip (23.7 KB, 48 views)
Mar 26 '20 #4
twinnyfo
3,653 Expert Mod 2GB
Also, I would add that you identify the actual server name for your file locations, so that driver letter registry is immaterial.

For example, instead a file path and file name looking like this:

Expand|Select|Wrap|Line Numbers
  1. J:\WorkingFiles\Sales\Invoices\2020-03-26-0001.pdf
Your file path and file name would look like this:

Expand|Select|Wrap|Line Numbers
  1. \\ServerName\SuperCorp\MechanicalDivision\WorkingFiles\Sales\Invoices\2020-03-26-0001.pdf
This may cause additional work to determine which organizations are mapped to which folders/drive letters. But, I have found in my office, that folks are no longer using the drive letters, but are jumping directly to the fully named locations. By adding shortcuts or links to the Quick Access list, there is no longer a need (in my opinion) for assigned drive letters.

Just my two cents--but I know this does not specifically address your question.
Mar 26 '20 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dan | last post by:
In a VS.NET 2003 project automatically generating the XML documentation on build I have some .CS files which lack comments as they are automatically created by tools (such as strongly typed DataSet...
1
by: dazza000 | last post by:
Hi I wan't to write a file renaming utility that is integrated with windows. for example: you open a normal folder, select one or multiple files, then hava a vb dialog box come up with new file name...
3
by: sunilrkp | last post by:
javascript code to save the contents of a textarea to a file using FIleDialog.
16
by: technocraze | last post by:
Hi pals, I would like to know how to display the FileName of the selected file in the textbox and open it using FileDialog property. I have imported the necessary reference from the library -...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
1
by: TonyJ | last post by:
Hello! I use this static method GetFiles from the Directory class and I hope to get only those files that have file extension ini but I get all files that begin with ini as the file extension...
3
by: Gary | last post by:
Hi all, I am writing an application which will intake arguments of filenames for processing: e.g. MyApp.exe "C:\abc.txt" "C:\def.doc" - then, MyApp will process the 2 files by parsing the...
2
by: sajtovi007 | last post by:
Hi, I've found code in thread: Using FileDialog property to open File and display FileName in a textbox but: 1. I do not know how to add it in to ACCESS 2003 database. 2. I have fields in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.