473,804 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP! Strange behavior in A2K3 Dir function

Hi Folks,

We have a solid, five year old Access app that is suddenly behaving
oddly after conversion to Access 2002/2003 format. Everything seems
to run OK except for a few oddities. The code below is a test form I
created to demo the problem. It has a single text box and a command
button with the code below. It's function is to determine if a
particular folder exists or not. Please note that this code has
worked just fine for several years. NOW it throws a runtime error if
the folder does not exist.

Example: I have the following drives on my PC:

C: (Primary disk drive)
D: (Secondary disk drive)
E: (a DVD RO drive)
F: (a CDRW drive)

Both the C and the D drives have a folder called "LEADS"

The code below returns the word "LEADS" for both of those drives.
However, when I specify the path name "E:\LEADS" or "F:\LEADS", the
code below throws a Runtime Error 52: Bad file name or number".
It does this EVENT IF I SPECIFY: On Error Resume Next OR if I include
a case for Error 52 in the Error trap (like the sample below.

It NEVER did this before being converted to Access 2002/2003 format

Does anyone have a clue why this is happening -- and ESPECIALLY why
the Resume Next option does NOT trap this error?

=============== ========= BEGIN CODE =============== ========
Private Sub cmdIsPath_Click ()

Dim msg As String

On Error GoTo cmdIsPath_Click _Error

msg = Dir(Me.txtPath, vbDirectory)

MsgBox msg, vbInformation, "IsPath?"

'======= ERROR HANDLER =============== ========
ExitHere:
On Error GoTo 0
Exit Sub

cmdIsPath_Click _Error:
Select Case Err.Number
Case 52
Resume Next
Case Else
MsgBox "ERROR: " & Err.Number & " (Line: " & Erl & "): " &
Err.Description & _
" in procedure: cmdIsPath_Click of VBA Document
Form_AAAAA_TEST _DIR Function " & _
" ," & vbCritical, "Sorry. An error has occurred ..."
End Select
End Sub

Nov 13 '05 #1
8 2425
Lauren,
For all intents and purposes your code should work. Perhaps you have a
reference that is in "Missing" status? This can tend to cause strange
errors.

Also, I would like to suggest that if you are trying to determine if
the folder exists or not, that you use the "FolderExis ts" function of
the Microsoft Scripting Runtime, which returns a boolean true or false
if the folder exists.

Create a reference to the Microsoft Scripting Runtime, then create this
function;

Function IsFolder(strFol derName) as Boolean
Dim fso as FileSystemObjec t
Set fso = New FileSystemObjec t
IsFolder = fso.FolderExist s(strFolderName )
End Function

If you then call this function by using IsFolder("E:\LE ADS") it will
return true or false. It's nice too because you can use it all over
your application for any folder you like.

HTH!

Nov 13 '05 #2
I just tried this in Access 2003 and it works fine. Since this happened
during an upgrade of the database, I'm going to guess that there is a
References problem. Does the old database work if you open it in Access 2003
without upgrading it?

For information on References, see this link:
http://www.allenbrowne.com/ser-38.html

--
Wayne Morgan
MS Access MVP
"Lauren Wilson" <no****@private .com> wrote in message
news:40******** *************** *********@4ax.c om...
Hi Folks,

We have a solid, five year old Access app that is suddenly behaving
oddly after conversion to Access 2002/2003 format. Everything seems
to run OK except for a few oddities. The code below is a test form I
created to demo the problem. It has a single text box and a command
button with the code below. It's function is to determine if a
particular folder exists or not. Please note that this code has
worked just fine for several years. NOW it throws a runtime error if
the folder does not exist.

Example: I have the following drives on my PC:

C: (Primary disk drive)
D: (Secondary disk drive)
E: (a DVD RO drive)
F: (a CDRW drive)

Both the C and the D drives have a folder called "LEADS"

The code below returns the word "LEADS" for both of those drives.
However, when I specify the path name "E:\LEADS" or "F:\LEADS", the
code below throws a Runtime Error 52: Bad file name or number".
It does this EVENT IF I SPECIFY: On Error Resume Next OR if I include
a case for Error 52 in the Error trap (like the sample below.

It NEVER did this before being converted to Access 2002/2003 format

Does anyone have a clue why this is happening -- and ESPECIALLY why
the Resume Next option does NOT trap this error?

=============== ========= BEGIN CODE =============== ========
Private Sub cmdIsPath_Click ()

Dim msg As String

On Error GoTo cmdIsPath_Click _Error

msg = Dir(Me.txtPath, vbDirectory)

MsgBox msg, vbInformation, "IsPath?"

'======= ERROR HANDLER =============== ========
ExitHere:
On Error GoTo 0
Exit Sub

cmdIsPath_Click _Error:
Select Case Err.Number
Case 52
Resume Next
Case Else
MsgBox "ERROR: " & Err.Number & " (Line: " & Erl & "): " &
Err.Description & _
" in procedure: cmdIsPath_Click of VBA Document
Form_AAAAA_TEST _DIR Function " & _
" ," & vbCritical, "Sorry. An error has occurred ..."
End Select
End Sub

Nov 13 '05 #3

Thanks Wayne. I'll verify this. But last time I checked the refs,
there were none showing missing.
On Thu, 23 Jun 2005 21:46:25 GMT, "Wayne Morgan"
<co************ *************** @hotmail.com> wrote:
I just tried this in Access 2003 and it works fine. Since this happened
during an upgrade of the database, I'm going to guess that there is a
References problem. Does the old database work if you open it in Access 2003
without upgrading it?

For information on References, see this link:
http://www.allenbrowne.com/ser-38.html


Nov 13 '05 #4

Thanks a LOT Wolf. I just KNEW there had to be a more elegant way to
do this, but, as you probably know, "when it ain't broke, we don't fix
it." This just became the squeaky wheel.

I will implement your solution immediately. However, I'm still bugged
about why the old approach worked for a long time and then stopped
working suddenly. I hate loose ends.
On 23 Jun 2005 14:43:37 -0700, "Wolf" <sp************ *@hotmail.com>
wrote:
Lauren,
For all intents and purposes your code should work. Perhaps you have a
reference that is in "Missing" status? This can tend to cause strange
errors.

Also, I would like to suggest that if you are trying to determine if
the folder exists or not, that you use the "FolderExis ts" function of
the Microsoft Scripting Runtime, which returns a boolean true or false
if the folder exists.

Create a reference to the Microsoft Scripting Runtime, then create this
function;

Function IsFolder(strFol derName) as Boolean
Dim fso as FileSystemObjec t
Set fso = New FileSystemObjec t
IsFolder = fso.FolderExist s(strFolderName )
End Function

If you then call this function by using IsFolder("E:\LE ADS") it will
return true or false. It's nice too because you can use it all over
your application for any folder you like.

HTH!


Nov 13 '05 #5

Just confirmed it. All refs in place. Go figure.
On Thu, 23 Jun 2005 19:28:05 -0500, Lauren Wilson <no****@private .com>
wrote:

Thanks Wayne. I'll verify this. But last time I checked the refs,
there were none showing missing.
On Thu, 23 Jun 2005 21:46:25 GMT, "Wayne Morgan"
<co*********** *************** *@hotmail.com> wrote:
I just tried this in Access 2003 and it works fine. Since this happened
during an upgrade of the database, I'm going to guess that there is a
References problem. Does the old database work if you open it in Access 2003
without upgrading it?

For information on References, see this link:
http://www.allenbrowne.com/ser-38.html


Nov 13 '05 #6
If that's the case, try unchecking one, click Ok, then go back and check it
again. This may "reset" the References. Remember which one you unchecked
because when you go back to check it again, it will be in alphabetical
order, not at the top with the checked references. You may not be able to
uncheck all of the references, so if you run across one that won't let you
uncheck it, just try another one.

Doing this should also decompile the code. When you recheck the reference,
click Ok, then go to Debug|Compile DatabaseName to recompile the code. Note
any errors that the compiler finds. This may give you a clue as to where to
look. Also, it is possible that the decompile/recompile will fix the problem
and you'll see no errors.

--
Wayne Morgan
MS Access MVP
"Lauren Wilson" <no****@private .com> wrote in message
news:t8******** *************** *********@4ax.c om...

Just confirmed it. All refs in place. Go figure.
On Thu, 23 Jun 2005 19:28:05 -0500, Lauren Wilson <no****@private .com>
wrote:

Thanks Wayne. I'll verify this. But last time I checked the refs,
there were none showing missing.
On Thu, 23 Jun 2005 21:46:25 GMT, "Wayne Morgan"
<co********** *************** **@hotmail.com> wrote:
I just tried this in Access 2003 and it works fine. Since this happened
during an upgrade of the database, I'm going to guess that there is a
References problem. Does the old database work if you open it in Access
2003
without upgrading it?

For information on References, see this link:
http://www.allenbrowne.com/ser-38.html

Nov 13 '05 #7
On Fri, 24 Jun 2005 15:03:58 GMT, "Wayne Morgan"
<co************ *************** @hotmail.com> wrote:
If that's the case, try unchecking one, click Ok, then go back and check it
again. This may "reset" the References. Remember which one you unchecked
because when you go back to check it again, it will be in alphabetical
order, not at the top with the checked references. You may not be able to
uncheck all of the references, so if you run across one that won't let you
uncheck it, just try another one.

Doing this should also decompile the code. When you recheck the reference,
click Ok, then go to Debug|Compile DatabaseName to recompile the code. Note
any errors that the compiler finds. This may give you a clue as to where to
look. Also, it is possible that the decompile/recompile will fix the problem
and you'll see no errors.


Thanks again Wayne. I often use the /decompile command line option
for starting the mdb but I did not know that unchecking references
would force a decompile/recomplie.

This group is so awesome!
Nov 13 '05 #8
On Fri, 24 Jun 2005 14:38:37 -0500, Lauren Wilson <no****@private .com> wrote:
On Fri, 24 Jun 2005 15:03:58 GMT, "Wayne Morgan"
<co*********** *************** *@hotmail.com> wrote:
If that's the case, try unchecking one, click Ok, then go back and check it
again. This may "reset" the References. Remember which one you unchecked
because when you go back to check it again, it will be in alphabetical
order, not at the top with the checked references. You may not be able to
uncheck all of the references, so if you run across one that won't let you
uncheck it, just try another one.

Doing this should also decompile the code. When you recheck the reference,
click Ok, then go to Debug|Compile DatabaseName to recompile the code. Note
any errors that the compiler finds. This may give you a clue as to where to
look. Also, it is possible that the decompile/recompile will fix the problem
and you'll see no errors.


Thanks again Wayne. I often use the /decompile command line option
for starting the mdb but I did not know that unchecking references
would force a decompile/recomplie.


Yes, it does, but it's not as thorough. Sometimes, you still need the
/decompile.
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6567
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to reformatting my system. Prior to the reformatting, I copied the help.rtf file onto a CD and checked the box to...
9
4420
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with the microsoft HTML workshop utility, lets call it c:\path\help.chm. My question is how do you launch it from the GUI? What logic do I put behind the "help" button, in other words. I thought it would be os.spawnv(os.P_DETACH,...
4
3359
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to cmd.Cmd but I would also like to get the man-page-like help for classes and functions. Does anyone know how to do that? Thanks. Sarir
2
6489
by: Sudheer Kareem | last post by:
Dear All Please tell me how to assosiate help files with my Vb.net Project. Regards Sudheer
3
3370
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
7
5398
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not most, keywords. Is there any way I can activate these "missing" help topics? HELP!
5
3292
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time using "F1" help within the VB IDE. Is this expectation achievable In trying to test my help file in the IDE, I have a solution with 2 projects: the DLL and a tester. VB does not look for my help file; instead, it looks for path to my source code...
8
3240
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both including search the internet for help, but the help is worthless. Any ideas?
10
3375
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
0
2899
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application calls MS Excel, so the scenario is that I am supposed to see the Excel Menu bar, FILE EDIT VIEW INSERT ... HELP. I am able to see the menu bar, but in case of Help, I see the Help of Excel and help of my application, both as a submenu of help. ...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9171
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.