Results 1 to 11 of 11
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Dir command (A2002)

    When I use the Dir command I get an error message "Invalid procedure call or argument".
    I have code similar to:
    <pre> Dim strMatch As String
    DoCmd.SetWarnings False
    strPath = DLookup("PathofXLS", "tbl 00 Control")
    strMatch = Dir(strPath & IIf(Right(strPath, 1) = "", "", "") & "*.xls")
    If strMatch = "" Then Exit Sub
    Set dbs = CurrentDb
    Do While strMatch <> ""
    .
    .
    .
    .
    Name strPathandFilename As strPathofSavedXLSFilesAndFilename
    strMatch = Dir <------------------ it fails here
    Loop
    </pre>


    Would somebody please

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dir command (A2002)

    Pat,

    There's nothing wrong with the Dir command lines, so I suspect that something else is causing the problem. What happens if you comment out the line just before the one that fails? One thing to watch out for is that if you change folders for any action, it knocks Dir (with no arguments) sideways. How are you populating the variables strPathandFilename and strPathofSavedXLSFilesAndFilename?
    Charlotte

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Dir command (A2002)

    Hi Charlotte
    I have already tried to comment out the prior line (this was renaming the file just processed to another directory). This worked fine in A2000.
    I initially developed this app in A2000 and have just recently been using A2002 to use it. Should I convert it fro A2000 to A2002?

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dir command (A2002)

    I really don't know. I haven't had any problems between 2000 and 2002 apps so I'm at a loss. However, if you have both versions on the same machine, make sure you have O2k SP-3 applied or you could have problems in 2000 apps.
    Charlotte

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Dir command (A2002)

    No I only have A2002 on this machine. I may have to alter the code to populate an array with all the relevant files in the directory and then loop using the array. That's if this way works of course. I'll give it a go.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Dir command (A2002)

    Hi Pat,

    I just tried your code (adapting the path of course) in Access 2002, in a database that has Access 2000 format. The Dir instruction worked as intended. So I suspect that there must be some other problem in your database. Have you checked Tools | References...?

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Dir command (A2002)

    Hi Charlotte
    I changed the program to read the filenames into an array, then changed my main loop to go thru the array items. This worked like a charm. I would like to know why it does not like my main loop, but then again ???

  8. #8
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Dir command (A2002)

    Yes I have checked Tools/References for missing references, and there are none.

    Is there something that should be checked in XP that A2000 doesn't require?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Dir command (A2002)

    >> Is there something that should be checked in XP that A2000 doesn't require?

    No, not that I know of. I can't explain this...

  10. #10
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Dir command (A2002)

    I thought I would respond to this again. What you say about the dir with no arguments being knocked aside sounds feasible. In other parts of this form I have a similar although far less code and it works just fine. I could experiment with the larger code loop, but what's the point. Strange that it works ok in A2000.

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dir command (A2002)

    I ran into the same issues and took the same workaround path last year when I needed to handle files that were being transmitted over phone lines. I was moving files and found Dir didn't behave as expected under those circumstances ... and that was Access 97.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •