Link to home
Start Free TrialLog in
Avatar of Rob4077
Rob4077Flag for Australia

asked on

DoCmd.TransferDatabase to DBase III - how

Can anyone tell me what is wrong with the following code. When I run it from I get a message to say that
"C:\Documents and Settings\Rob\My Documents\MyDatabase.accdb is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides." If I run it manually it works fine.

DoCmd.TransferDatabase acExport, "dBase III" _
      , CurrentDb.Name, _
      acTable, _
      "tblTempOutput", _
      "C:\Documents and Settings\Rob\My Documents\Out.dbf"
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

1. <When I run it from I get a message >
When you run it from what?

<If I run it manually it works fine.>
As far as I know, there is only one way to "Run" code.
Can you explain what this means?

3. Is the code you posted the code that works, or the code that does not work?

First let's get rid of the line contiuation charachters so we can see if this doesn't have anything to do with the error.
Then try this (the attached snippet) just as a test, to see if it is just not liking the spaces in the path:

JeffCoachman
DoCmd.TransferDatabase acExport, "dBase III", CurrentDb.Name, acTable, "tblTempOutput", "C:\Out.dbf"

Open in new window

Then try this:
(Perhaps we can get around it by using the Dos 8.3 syntax:
DoCmd.TransferDatabase acExport, "dBase III", CurrentDb.Name, acTable, "tblTempOutput", "c:\Docume~1\Rob\MYDOCU~1\Out.dbf

Open in new window

sorry, forgot the last "

DoCmd.TransferDatabase acExport, "dBase III", CurrentDb.Name, acTable, "tblTempOutput", "c:\Docume~1\Rob\MYDOCU~1\Out.dbf"

Open in new window

Avatar of Rob4077

ASKER

Hi Jeff,
First I will answer your questions:
1. <When I run it from I get a message > When you run it from what?
I created a Sub in a module of the database that contains the table I want to transfer from and I step through the code pressing the F8 key. When it gets to that line it jumps to the error handler with the described message

<If I run it manually it works fine.>
As far as I know, there is only one way to "Run" code. Can you explain what this means?
Badly worded, sorry. If I manually transfer the table using the menu options in MS Access 2007 External Data>Export>More>DBase file .... the file exports perfectly

3. Is the code you posted the code that works, or the code that does not work?

 The code I posted is the code that doesn't work. Your code (both variants) comes up with the same error. Please note that the file described by the error message as being invalid is the file location of CurrentDb.name. That name is managed by MS Access so I don't understand how it can be wrong. The table name is correct as I have copy and pasted it to ensure it is spelled correctly.
The try fully qualifying it:

DoCmd.TransferDatabase acExport, "dBase III", "C:\YourFolder\YourDatabase.mdb", acTable, "tblTempOutput", "C:\Out.dbf"
 

DoCmd.TransferDatabase acExport, "dBase III", "C:\YourFolder\YourDatabase.mdb", acTable, "tblTempOutput", "C:\Out.dbf"

Open in new window

Avatar of Rob4077

ASKER

I had already tried that but got the same error message. I even tried a decompile in case there was a problem at a lower level
OK

1. What happens if you change the format to "Microsoft Access"

2. You may need to Re-install Accessmaking *sure* you do a full install.
(to make sure the DBase components are installed.)
Avatar of Rob4077

ASKER

I tried changing the format change as suggested and irrespective of whether I use "C:\Out.dbf" or "C:\Out.mdb" or "C:\Out.accdb" the error message I get is that the file name doesn't conform to Microsoft naming conventions.
I fear you may be right in that I need to do a complete re-install.  It's odd, though, that it works fine when I use the manual method using the menus.
ASKER CERTIFIED SOLUTION
Avatar of Rob4077
Rob4077
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob4077

ASKER

Thanks for your time trying to help on this one. I would never have expected MS Access help to be wrong!