Access VBA Path Problem on Import

Posted on 2009-04-21
Last Modified: 2012-05-06
I am trying to do an an import for a dBase III file.  It works fine in Access when I navigate to the file and use the built-in Import.  You can see in my code that I have a Dir run first.  The Dir finds the file fine; yet, the docmd aborts with error 3044, invalid path name.  The variable strPath is a Variant.  (I've also tried String.)

I don't understand how Dir finds the file and considers it ok, but docmd fails.

Can anyone help on this?
If Dir(strPath) <> "" Then

    DoCmd.TransferDatabase acImport, "dBase III", strPath, acTable

  End If

Open in new window

Question by:vlvawter
    LVL 77

    Expert Comment

    You need to see what is being used.

    Insert a
    Debug.Print strPath
    between lines 1 & 2 and see what appears in the Immediate window.
    LVL 7

    Expert Comment

    Does "strPath" contains the full drive/path/filename? Are spaces or special characters used?

    Author Comment

    strPath is 100% correct.  If it weren't then If Dir(strPath) would not work.  

    Yes, there is a spacke in one of the folders in the path.  I adjusted strPath to be chr(34) & strPath & chr(34).  It still didn't work.  I keep coming back to Dir(strPath).  The space is in it, but it still works.

    I've stepped through the code with F8.  Dir(strPath) is ok.  The error occurs on the next line.
    I've stopped the code and checked strPath with the actual path name.  It matches letter for letter.
    LVL 65

    Accepted Solution

    dont you need to specify a source tablename?

    what is strPath, does it point to a folder or your dbase file?

    I would say the file ending with your suffix should be specified in the source table
    the database path is then either just the folder or full dbase path

    DoCmd.TransferDatabase acImport, "dBase III", strPath, acTable, "nameofmydbffileonly","myaccesstable")


    DoCmd.TransferDatabase acImport, "dBase III", "c:\placewheremydbasefileis", acTable, "nameofmydbffileonly","myaccesstable")

    LVL 65

    Expert Comment

    urm, rogue ) in suggested code

    Author Closing Comment

    Rockie, Your 2nd option did it.  I had used that earlier, but I had left the filename per se on strPath.  Thanks.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now