Doubleclick a list box to open a folder

Brando

Enthusiastic Novice
Local time
Today, 09:11
Joined
Apr 4, 2006
Messages
100
Hi,

I'm having trouble finding the correct code to open a network folder by double clicking on a record in a listbox on a form.

The folder names are the record IDs. Any help is appreciated.

The code I have been messing with is:

Application.FollowHyperlink "\\Storehouse1\Admin\ClientLibrary\2009\& Me![lstbxClients]![RecordID]"
 
Application.FollowHyperlink "\\Storehouse1\Admin\ClientLibrary\2009\& Me![lstbxClients]![RecordID]"

that should work fine, but you're not concatenatiing correctly. it should be this:
PHP:
Application.FollowHyperlink "\\Storehouse1\Admin\ClientLibrary\2009\'" & forms![lstbxClients]column(column number of the field in the LB) & "'"
all controls need to be concated outside other stand-alone strings in order to work.

column numbers start at 0. the index does, that is.
 
I tried several variations on what you suggested. However, I get a compile error each time. I must be missing something simple. I tried...

....'" & forms![lstbxClients]column(4) & "'"
....'" & forms![lstbxClients]column4 & "'"
....'" & forms![lstbxClients](4) & "'"
....'" & forms![lstbxClients]4 & "'"
 
You were close, but not quite there:

...." & forms![lstbxClients].Column(4)

And you don't need the single quotes.

And if you use Column(4) it is the 5th column (so if you want the 4th column it would be .Column(3) )
 
I put in exactly what you suggested but got an error that Access couldn't find the form referred to in the expression. The form is called frmClientFiles, the listbox on the form is lstbxClients. I tried more combinations but am still missing something. Do I need to include the name of the form before the listbox?
 
Based on what you've given if the code is ON the form in question:
Code:
Dim strPath As String
strPath = ""\\Storehouse1\Admin\ClientLibrary\2009\" & Me.lstbxClients.Column(4)"
Application.FollowHyperlink strPath

If not on the form:
Code:
Dim strPath As String
strPath = ""\\Storehouse1\Admin\ClientLibrary\2009\" & Forms!frmClientFiles.lstbxClients.Column(4)"
Application.FollowHyperlink strPath
 
The list box and the code are all on the form. However, when I run your "on the form" sample, I get a compile error: Expected: expression, and it highlights the second \ in the strPath (right before Storehouse1). I don't know why this one is so tough!
 
OOPS! remove the second quote just before the \\ part.
 
Bob, I am an Access novice, but even I know that you can't have an odd number of quotes. So if I remove that one, do I remove or add another?
 
Bob, I am an Access novice, but even I know that you can't have an odd number of quotes. So if I remove that one, do I remove or add another?
There won't be an odd number because there is now an odd number. You have the matching one that falls:


ClientLibrary\2009\"
 
Thank you Bob. Whew! Upon removing the quotes at the begining and the end, it works perfectly. The working code is:

Dim strPath As String
strPath = "\\Storehouse1\Admin\ClientLibrary\2009\" & Me.lstbxClients.Column(4)
Application.FollowHyperlink strPath
 

Users who are viewing this thread

Back
Top Bottom