We just moved our database to a more secure volume, and everything is great except for one thing: I have a button on a form that opens a specific folder based on the record in hand. The path is pretty simple (it used to be "V:\Pre-Admitting\eCharts\"), and it worked like a charm. The new location is "V:\IUR\eCharts", but when I replaced the string in my code, I get a "Path not found" error.
I can't figure out what's wrong, since the permissions are correct (I can navigate to the path outside of the database), and the path does actually exist, and it worked great with the old address.
Here's the code: - Private Sub Open_eChart_Click()
-
On Error GoTo Err_Open_eChart_Click
-
-
Dim retVal As Variant
-
Dim strPartialPath As String
-
Dim intCounter As Integer
-
Dim strThisChar As String
-
Const conPAth As String = "V:\IUR\eCharts\"
-
-
If Not IsNull(Me![ChartNum]) Then
-
If Left$(Me![ChartNum], 1) = "\" Then
-
strPartialPath = Mid$(Me![ChartNum], 2)
-
Else
-
strPartialPath = Me![ChartNum]
-
End If
-
Else
-
Exit Sub
-
End If
-
-
'Replace any commas with underscores
-
For intCounter = 1 To Len(strPartialPath)
-
strThisChar = Mid(strPartialPath, intCounter, 1)
-
If strThisChar = "," Then
-
strPartialPath = Left(strPartialPath, intCounter - 1) & _
-
"_" & _
-
Mid(strPartialPath, intCounter + 1, 255)
-
End If
-
Next
-
-
If Dir$(conPAth & strPartialPath, vbDirectory) <> "" Then
-
retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbNormalFocus)
-
Else
-
MkDir (conPAth & strPartialPath)
-
retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbNormalFocus)
-
End If
-
-
Exit_Open_eChart_Click:
-
Exit Sub
-
-
Err_Open_eChart_Click:
-
MsgBox Err.Description
-
Resume Exit_Open_eChart_Click
-
-
End Sub
-
Any help will be greatly appreciated!
Not sure about the PATH Error, but I do believe that your Code can be simplified and made more efficient: - Dim retVal As Variant
-
Dim strPartialPath As String
-
Const conPAth As String = "V:\IUR\eCharts\"
-
-
If IsNull(Me![ChartNum]) Then Exit Sub
-
-
strPartialPath = Replace(Replace(Me![ChartNum], "\", ""), ",", "_")
-
-
If Dir$(conPAth & strPartialPath, vbDirectory) = "" Then MkDir (conPAth & strPartialPath)
-
-
retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbNormalFocus)
3 1480
Not sure about the PATH Error, but I do believe that your Code can be simplified and made more efficient: - Dim retVal As Variant
-
Dim strPartialPath As String
-
Const conPAth As String = "V:\IUR\eCharts\"
-
-
If IsNull(Me![ChartNum]) Then Exit Sub
-
-
strPartialPath = Replace(Replace(Me![ChartNum], "\", ""), ",", "_")
-
-
If Dir$(conPAth & strPartialPath, vbDirectory) = "" Then MkDir (conPAth & strPartialPath)
-
-
retVal = Shell("Explorer.exe " & conPAth & strPartialPath, vbNormalFocus)
This IS nicer, thanks!
It turns out that the "path not found" is a function of how the new location was set up, so IT is fixing that. But I'm really glad I asked, since it garnered me this nice code simplification. :)
NeoPa 32,556
Expert Mod 16PB
With just a quick glance I can only say that the formats of the old and new folder strings are different - the newer one being without a closing "\".
Good code in this area should handle that by using something like : - FullPath = PathString & "\" & FileName
-
FullPath = Replace(FullPath, "\\", "\")
That way such oversights don't cause issues.
I expect ADezii's code does something on similar lines.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: learningGuy |
last post by:
Can someone tell me what is wrong with this simple code?
I get an exception every time at the myFile.Open() line.
I have included the code that I think is needed to for you to answer this
below:...
|
by: Christopher |
last post by:
One of our ASP.NET Pages is starting a new Process using the Process object.
When the process starts, it is started under the ASPNET User. We tried
editing the web.config file and the...
|
by: bbcrock |
last post by:
I have some modular code that is written for display purposes. It
contains inline CSS code. I originally thought about moving all the
inline code to a css file for use throughout the site- one...
|
by: Nalaka |
last post by:
Hi,
I have some request specific data that gets created in a "early event", that
I need to pass around to many other events.
I need access to this data during that request.
(and more importantly...
|
by: Cleo |
last post by:
How would I hard code a certain variable to be stored in a specific memory location in a processor. When I declare a variable in my program, the linker automatically determines a location and assigns...
|
by: Screaming Eagles 101 |
last post by:
Hi,
I found out that the Windows Generated Code is now in a new file
myform.designer.vb ,
Through Add File I couldn't add the code to the project to see it, I had to
go through Explorer and...
|
by: mcnews |
last post by:
How can I direct Response.Write to output to a specific location on my
page?
TIA,
mcnewsxp
|
by: Lior |
last post by:
Hi,
I have small code, that compiles on Visual C++ into a shared library
(DLL).
I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD,...
|
by: =?Utf-8?B?QXZhRGV2?= |
last post by:
ASP.Net 2.
We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003
32 Bit with IIS 6. A few library classes we wrote uses impersonation in code
like explained in this...
|
by: lacole |
last post by:
I have an .exe program written in C# that will not run on a specific PC that has Windows XP on it. That same .exe program will run on other Windows XP PCs though. So it's something specific to that...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |