Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    4

    Exclamation Unanswered: VBA TransferDatabase Nightmare - Please wake me! Error 3011 - File Not Found

    Hello,

    I'm having an issue with the following piece of code. This is what it looks like:

    Dim loc As String
    loc = Me.cmbDriveLtr.Value & ":\directory1\directory2\" & Me.numloccode.Value
    DoCmd.TransferDatabase acImport, "ODBC", "ODBC;DSN=FoxPro Files - Word;SourceDB=" & loc & ";SourceType=DBF;Exclusive=No;BackgroundFetch=Yes; Collate=Machine;Null=Yes;Deleted=yes;;TABLE=gmgm", acTable, "gmgm", "gmgm", False

    Strange thing here is this - if I move the file (gmgm) back into the \directory2 instead of the directory specified by me.numloccode.value, it's imported as planned - however, if the file is not in directory2, Access/VBA fails to find the file. Its almost like the system isn't seeing the "me.numloccode.value" taken from the form, but when I do a debug.print in my code, the loc variable is set correctly, and the path is existant.

    Needless to say, I'm just baffled. Probably because I'm just a simple caveman. Your big computers frighten and confuse me. I have bad dreams about VBA. I don't know alot about this strange world, but I do know this: I need some serious help with this problem! Anyone have any clues? Any help is greatly aprieciated. Thanks.

    - Me
    Last edited by MeanDude; 11-19-04 at 20:18.

  2. #2
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    Had a very quick skim over your code and the major thing that strikes me is that you have already defined that the loc is drive:directory1\directory2\Me.numloccode.Value
    Hence if the file is not in directory2 it will never find the file check the variable loc to see if you are pointing in the correct location,

    Thats just a quick observation.

  3. #3
    Join Date
    May 2004
    Posts
    97
    Have you tried putting a trailing \ on your directory?

    loc = Me.cmbDriveLtr.Value & ":\directory1\directory2\" & Me.numloccode.Value & "\"

    I can't see where it would affect it, but ya never know.

  4. #4
    Join Date
    Nov 2004
    Posts
    4

    Thanks - Got it figured out (I think)

    Hey,

    Thanks. I got the problem figured out. The thing didn't seem to be able to digest the entire connect string. After a quick "change up" on the syntax, it seems to work. BTW, here's what I finally came up with.

    DoCmd.TransferDatabase acImport, "ODBC", "ODBC;DSN=Visual Foxpro Tables;SourceDB=" & loc, acTable, "trip_exc", "trip_exc", False

    Guess the trick is to leave the database name out of the connectstring and save it for the next argument? Oh well - it works! Thanks again for your help.

    - D

Posting Permissions

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