Problem opening PDF files on server

esskaykay

Registered User.
Local time
Today, 07:30
Joined
Mar 8, 2003
Messages
267
Hello,
This may be a bit confusing but…

We have a database (CardFile) that tracks plan files. There is a command button on a search form that after running a select query, opens the corresponding file. In most instances this works fine, except when attempting to open PDF’s on one machine. They open in about 5 seconds on all machines except on the newest (and most powerful) machine where it takes almost a minute. The files reside on our server. As a test, I moved all files to the local machine; recoded the command button; and tested. The PDF file opened < 2 seconds. So, for some reason, this machine can’t search the server as fast/well as all others. I spoke to our IT guys but no luck.

Here’s part of the code that appears to be cumbersome:

strPathAndFile = fReturnFilePath(Me.PlanNo1 & ".pdf", \\10.10.30.40\city_engr\cad_files\plans\")
If strPathAndFile <> "" Then
objshell.ShellExecute strPathAndFile, 4, 2
GoTo GoodBye
End If

10.10.30.40 is the IP of our server (aka city_server). We map \\10.10.30.40\city_engr\cad_files\ as drive Z:. So I tried (but did not work):

strPathAndFile = fReturnFilePath(Me.PlanNo1 & ".pdf", z:\plans\")
If strPathAndFile <> "" Then
objshell.ShellExecute strPathAndFile, 4, 2
GoTo GoodBye
End If

When I copied all files to the local drive I recoded as follows (it worked perfect):

strPathAndFile = fReturnFilePath(Me.PlanNo1 & ".pdf", c:\plans\")
If strPathAndFile <> "" Then
objshell.ShellExecute strPathAndFile, 4, 2
GoTo GoodBye
End If

Any other suggestions would be greatly appreciated?

Thanks,
SKK
 
Originally I post his here: UtterAccess


First thing I noticed was a missing "
Code:
strPathAndFile = fReturnFilePath(Me.PlanNo1 & ".pdf", \\10.10.30.40\city_engr\cad_files\plans\")
is missing a " before the \\

I think it should be:
Code:
strPathAndFile = fReturnFilePath(Me.PlanNo1 & ".pdf", "\\10.10.30.40\city_engr\cad_files\plans\")

I would also change this line:
Code:
If strPathAndFile <> "" Then
to be
Code:
If Dir(strPathAndFile) > "" Then

So you would have:

Code:
strPathAndFile = fReturnFilePath(Me.PlanNo1 & ".pdf", " \\10.10.30.40\city_engr\cad_files\plans\")
If Dir(strPathAndFile) > "" Then
    objshell.ShellExecute strPathAndFile, 4, 2
    GoTo GoodBye
End If


I would urge consider rethinking the use of: GoTo GoodBye
I have found that the use of of GoTo can cause lots of issues and should be avoid whenever possible. AFAIK, professional VB/VBA programers consider avoiding the use of GoTo as a "Best Practice".
 

Users who are viewing this thread

Back
Top Bottom