[AccessD] DIR Command Failing-but not everywhere...

Greg Smith GregSmith at starband.net
Mon Oct 3 10:16:36 CDT 2005


I'm going to apologize for the ">" things now...I hate those...but my
ISP's webmail only provides these...

Rocky:  If the Dir() command doesn't find a file, then it's "supposed" to
return and empty string, "".  And what's even more ODD is that I got this
code from Microsoft's support in an article about Remote Shutdown of
Access databases...so it's THEIR idea really... ;)

Lambert:  Thanks.  I'll try that Function tonight when I get home to see
if it fixes the issue.  I'm still puzzled and worried about the fact it
(my current setup) won't work at a different installation...which may crop
up again when they update computers at the client's location now or if I
install it at new locations later.

I still wonder if it's something I've not added to the home computer (odbc
functionality or something like that...) that should be there or was
removed when I had to uninstall something (I had MS Office Accounting 2006
and MSDE installed but removed them both earlier).

Greg

> First of all, here's a better way to check if a file exists...
>
> Function FileExists(strFile As String) As Boolean
>   ' Comments  : Determines if the file exists
>   '             Works for hidden files and folders
>   ' Parameters: strFile - file to check
>   ' Returns   : True if the file exists, otherwise false
>   Dim intAttr As Integer
>   Dim errnum As Long
>   On Error Resume Next
>   'GET THE FILE ATTRIBUTE INSTEAD OF THE LENGTH OF THE FILE NAME
>   intAttr = GetAttr(strFile)
>   errnum = Err.Number
>   FileExists = (Err.Number = 0)
> End Function
>
> It's better in that it works for hidden filed and folder too.
>
> As for why Dir() on a non-existent folder/drive gives you the Error 52,
> I'm just as clueless as you are. On my (Access 2002) system
> Dir("G:\BHCRecorder\Scripts\chkfile.ozx") just returns an empty string
> (no G drive here either) - as it should do.
>
> Lambert
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Greg Smith
> Sent: Monday, October 03, 2005 10:26 AM
> To: accessd at databaseadvisors.com
> Subject: [AccessD] DIR Command Failing-but not everywhere...
>
>
> Hi everyone!  Hope you all are having a GREAT day!
>
> I've got a real puzzle here.  I'm using the Dir() command (Access 2003
> module) to find if a filename exists in a specific directory, or not.
> The exact syntax is shown below.  The code is checking for a specific
> file in two different directories (one exists at work, and one at the
> customer's), and if it can't find that file in either location, the
> application warns the user that it's not available right now and closes
> automatically.
>
> The code is:
>
>     strFileName = Dir("c:\MyData\chkfile.ozx")
>     strFileNameBHC = Dir("G:\BHCRecorder\Scripts\chkfile.ozx")
>     If strFileName <> "chkfile.ozx" And strFileNameBHC <> "chkfile.ozx"
> ...
>
> This code works perfectly at work and at the customer's.  So, you may
> ask, what's the big deal?  Well, I also work on this at home, and I just
> (within the last 3 weeks) reformatted my home computer (winXP),
> reinstalled everything (supposedly...), and service packed everything up
> to date.
>
> When I run this application at home, it fails on the Dir() command where
> the directory doesn't exist.  Since I'm at home, for example, I don't
> have a "G" drive and it fails on that one with the message "Bad Filename
> or Number", and the error number is 52.
>
> The application is identical in both places...that is, I take a copy
> home and put it on my computer, relink all the tables to the BE and
> everything else is the same.
>
> Either I've not installed something correctly at home, or I've not
> installed something I need to have.  Or both.  The references are all
> the same and none are missing at either location.
>
> Anyone else see this before?
>
> TIA!!
>
> Greg Smith






More information about the AccessD mailing list