Re: Q. Error when trying to do Dir, as stated from Access Help File.

From: Alphonse Giambrone (NOSPAMa-giam_at_example.invalid)
Date: 07/30/04


Date: Fri, 30 Jul 2004 14:59:56 -0400

Check out FileSearch in Help.
It might give you what you are looking for.

-- 
Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Jim" <spamproofemail@here.com> wrote in message
news:crqkg0hbco6jvalk9mtr9d0qa90o7agim9@4ax.com...
> Hi,
>
> Having read the many posts here about how to open and manipulate Text
> Files from within a Microsoft Access 2000 mdb file, I tried one from
> the Access Help file, regarding "Dir" to get started, and as I
> expected, I got an error, right off the bat.
>
> I get this error, when I click on the single form, in hopes of getting
> some kind of directory listing:
>
> "Run-time Error "5"  "
> Invalid Procedure Call or Argument
>
> Then, if I click "End" the message goes away, and nothing else
> happens.
>
> If I click on "Debug", it brings up the code window, and highlights
> the "MyFile  = Dir" statement (without any of the 'arguments'), and
> that's almost as helpful as when I clicked "End", the first time.
>
> I am clueless, Please help. Thanks, Jim
>
> Here is the code, I placed in my test datbase's "Load" event, in the
> only form (the code is straight from my Access 2000 help file example)
> on the "Dir" topic:
>
>
>
> Private Sub Form_Load()
> Dim MyFile, MyPath, MyName
>
> ' Returns "WIN.INI" (on Microsoft Windows) if it exists.
> MyFile = Dir("C:\WINDOWS\WIN.INI")
>
> ' Returns filename with specified extension. If more than one *.ini
> ' file exists, the first file found is returned.
> MyFile = Dir("C:\WINDOWS\*.INI")
>
> ' Call Dir again without arguments to return the next *.INI file in
> the
> ' same directory.
> MyFile = Dir
>
> ' Return first *.TXT file with a set hidden attribute.
> MyFile = Dir("*.TXT", vbHidden)
>
> ' Display the names in C:\ that represent directories.
> MyPath = "c:\"    ' Set the path.
> MyName = Dir(MyPath, vbDirectory)    ' Retrieve the first entry.
> Do While MyName <> ""    ' Start the loop.
>     ' Ignore the current directory and the encompassing directory.
>     If MyName <> "." And MyName <> ".." Then
>         ' Use bitwise comparison to make sure MyName is a directory.
>         If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory
> Then
>             Debug.Print MyName    ' Display entry only if it
>         End If    ' it represents a directory.
>     End If
>     MyName = Dir    ' Get next entry.
> Loop
>
>
> End Sub


Relevant Pages


Loading