A little problem

Lagwana

Registered User.
Local time
Today, 04:23
Joined
Jun 30, 2010
Messages
23
This seems ridiculous to ask, but can I put a button on a form that will take data from that particular form and open up a file based on putting together the seperate fields into one file name?
 
Would someone post an example that I can access? I am very lost with this problem.
 
It combines all the fields into one long string that is the file name, and then opens that particular file to be viewed.
 
something like this:
Code:
Dim strFile As String
Dim strPath As String

strFile = Me.YourTextboxWithFileNameHere

strPath = Me.yourTextBoxWithPathHere

FollowHyperlink strPath & "\" & strFile
 
Now I am getting the Run-Time Error '490': Cannot open the specified file.

This is after I used the source data to make the two text boxes that are being used. When I wrote the actual data into the text boxes it was fine. Now it is not. Any reason behind it?
 
Debug.print strPath & "\" & strFile

Copy and paste the result from the Immediate Window so we can see the output.
 
What immediate window? Nothing happens when I put that in......
 
In the VBE editor, go to TOOLS > IMMEDIATE WINDOW and a small window will pop-up at the bottom. The output will appear there.
 
R:\Peoples Back Ups\2010\2010 07 01 Folder\PDF's\\2010 07 01 10.pdf

This is what I get.
 
You seems to either have a missing or blank variable or a coding issue as you seem to have to \\ in the string.
 
If the backslash is included in the text box you would need to use

FollowHyperlink strPath & strFile

so you should probably test to see if it is there and add it if it isn't:

Code:
If Right(strpPath,1)="\" Then
    FollowHyperlink strPath & strFile
Else
    FollowHyperlink strPath & "\" & strFile
End If
 
I am still getting the same error. I have tried fiddling with it, but I am not getting anywhere. Is there something I am doing wrong?
 
I am still getting the same error. I have tried fiddling with it, but I am not getting anywhere. Is there something I am doing wrong?
So when you say you tried "fiddling with it" what do you mean exactly?

What is the current output from the Immediate Window when you run it?

Did you put the last code I gave in place EXACTLY as it was written or did you do some changes to it? If you made changes it is important to see what it is you actually are trying to use now.
 
I changed it, but that didn't work, so i put it back since what I did was too confusing, even for me. (I'm not surprised it didn't work.) The immediate window says "R:\Peoples Back Ups\2010\2010 07 01 Folder\PDF's\2010 07 01 10.pdf" which should bring it up.... I don't know.
 
What if you hard code it?

Application.FollowHyperlink "R:\Peoples Back Ups\2010\2010 07 01 Folder\PDF's\2010 07 01 10.pdf"

Also try:

Shell "R:\Peoples Back Ups\2010\2010 07 01 Folder\PDF's\2010 07 01 10.pdf"
 
Neither of the codes worked. I tried the first one and got the same error. I tried the second one and got "Runtime Error '52': File could not be found."

Thanks anyway.

Any other suggestions?
 
If you copy and paste your string listed above into the address bar of windows explorer, does the file open for you?

R:\Peoples Back Ups\2010\2010 07 01 Folder\PDF's\2010 07 01 10.pdf

I suggest you rename the PDF's folder to PFDs [without the apostrophy] since special characters can cause problems.
 
Try it on a simple path first like C:\Temp\Test.txt

If access says it dont exist, the there is either something wrong in the path or filename... It followhyperlink is not really bothered with ' or spaces, though in coding that can be a nightmare.
 

Users who are viewing this thread

Back
Top Bottom