Solved Open a specific folder using the first x letters (1 Viewer)

Minty

AWF VIP
Local time
Today, 02:40
Joined
Jul 26, 2013
Messages
10,371
It sounds like you need to find the letters up to the first space - or not if there isn't one.

Personally, I wouldn't use a company name as the folder name to store documents.
If the company have a unique account number in your system use that, and then you won't be trying to bodge your way around the inconsistencies!
 

dim

Registered User.
Local time
Yesterday, 21:40
Joined
Jul 20, 2012
Messages
54
I created a field [shortname] on the form which is Left([CompanyName],3)
So shortname on the form show TER and the name on the server is TERRA
I tried to use dir function to check if the fiolder exist and then open it:

strFoldername = Me.shortname
If Dir("\\datasrv\serverdata\Customer's Documents\PO\" & strFoldername, vbDirectory) = "" Then
MsgBox "Missing folder with this Company name"
Else
FollowHyperlink "\\datasrv\serverdata\Customer's Documents\PO\" & strFoldername & "*"
End If

My code is still not good.
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:40
Joined
Sep 21, 2011
Messages
14,350
I created a field [shortname] on the form which is Left([CompanyName],3)
So shortname on the form show TER and the name on the server is TERRA
I tried to use dir function to check if the fiolder exist and then open it:

strFoldername = Me.shortname
If Dir("\\datasrv\serverdata\Customer's Documents\PO\" & strFoldername, vbDirectory) = "" Then
MsgBox "Missing folder with this Company name"
Else
FollowHyperlink "\\datasrv\serverdata\Customer's Documents\PO\" & strFoldername & "*"
End If

My code is still not good.
No, you just pretty much have what you started with? No change really.? :(

From the link I posted they searched for the folder using the * ? You insist on using it with the Hyperlink, which we have already established, will not work?

So I would look at those links (pleanty more in the google link) and see how they accomplished it, and emulate that.?

FWIW you cannot compare TER with TERRA and expect to result to be true? Why you can't have the name of the folder the same as strFolderName is beyond me. :(
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:40
Joined
Sep 21, 2011
Messages
14,350
Perhaps consider a table with the 3 letter code and the real folder name?
Then you can use a DLookUp() with the 3 letter code and get real folder name?

You can also make sure you do not have duplicates that way as well?
 

dim

Registered User.
Local time
Yesterday, 21:40
Joined
Jul 20, 2012
Messages
54
Finally I found a solution to my problem.
I get the first word of the company name (TERRA) using: (instate of using the first 3 letters)

[shortname]=Left([CompanyName],InStr([CompanyName]," "))

and

strFoldername = Me.shortname
If Dir("\\datasrv\serverdata\Customer's Documents\PO\" & strFoldername, vbDirectory) = "" Then
MsgBox "Missing folder with this Company name"
Else
FollowHyperlink "\\datasrv\serverdata\Customer's Documents\PO\" & strFoldername
End If

Thanks for your help!
 

Minty

AWF VIP
Local time
Today, 02:40
Joined
Jul 26, 2013
Messages
10,371
This is still doomed to fail. Consider the following 3 organisations ;

The Good Pizza Firm
The Good Burger Joint
The Good Samaritans

What happens to your file structure.
You can't even strip out the "The" to get a sensible result.
Use or generate a unique ID for every client.
 

Users who are viewing this thread

Top Bottom