Access: Choose folder to Hyperlink

arcaidius

Board Regular
Joined
Dec 4, 2018
Messages
97
Good morning,

In my Access database form I have a hyperlink field that I would like to make a function, a button perhaps that will open a specific folder so the user can choose a folder to hyperlink, and the text displayed to say something like "view the employees folder"

If it was excel I could figure it out on my own, but access is a different beast.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Doesn't sound too hard but I don't understand your post. You want to open the folder that is showing in your form's hyperlink field? That's Application.Followhyperlink.

Or you want to select a folder and store the choice in the hyperlink field? That's done by using the msoFileDialog FolderPicker.
Or both, but the 2nd one comes first? Then folder dialog to store the link value, and code to follow it as well.

The "text" is to be shown where - the command button?
 
Upvote 0
Brother, I would recommend NOT trying to use a hyperlink field. Those are a pain. Here is a function that will prompt the user for selecting a folder in Windows. this isn't the EXACT code that I used for many years but it should do the trick.

Sub SelectFolder()
Dim sFolder As String
' Open the select folder prompt
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = -1 Then ' if OK is pressed
sFolder = .SelectedItems(1)
End If
End With

If sFolder <> "" Then ' if a file was chosen
' *********************
' put your code in here
' *********************
End If
End Sub

From: VBA Select Folder with msoFileDialogFolderPicker - wellsr.com

To be honest, I had an API call that I prefered to that method but I'm having trouble finding it, it's been a few years. This msoFileDialogFolderPicker is probably a safer method, then to trust random people online who give you API code to call. Cheers ,I hope that it helps.

and then on the OTHER side of the equation, if you do NOT use a hyperlink field, and if you need a button next to the field that will open that form, I think that you just call this code
Dim strShell as String
strShell = "EXPLORER.exe " + CHR(34) + me.folderPath + CHR(34)
Shell strShell

I'm pretty sure that will 'Open' the folder for the user, I hope that is what you are talking about, and I think that will do everything that your intention to use a Hyperlink will accomplish.

Now, if you want to display the FOLDER and have the user choose a file, THAT is something else entirely.

I haven't posted anyting on Access Forums for many years... Because I'm a known TROLL who is still PISSED that Microsoft killed off 'Access Data Projects'. Those were MUCH better solution than JET databases as they support stuff like Replication, Realtime Backups, Log Shipping, Auditing.

Damnit I wish that Office 2010 would still actvivate, because today, I'd still be using ADP if it still functioned. but Access 2019 is pretty slick.. they have fixed a couple of things over the years that make Access Databases a lot more acceptable, for example BIGINT support in linked tables. Cheers, and I hope that helps.
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,908
Members
448,532
Latest member
9Kimo3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top