Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Export Table Data To DBF

Status
Not open for further replies.

LOKIDOG

Technical User
Apr 25, 2001
150
US
I am trying to simply export data from a table to a dbf file (actually excell or txt file would work too). The only contraints are that is must be automated, and include the date in the name of the output file.

I would also like to delete all the records in the file beinig exported - but will probably not do both at the same time.

I'm exasperated and can't seem to do these very simple tasks and keep getting errors.

I'm not even sure 'where' to put the code or how to 'run' it if I indeed need VBA code - in a function? Doesn't seem to work. I've made a Macro to run the function still get errors (all kinds depending on what syntax I use)

There is a help pop-up with the command when I type in a coma (in the transferDatabase) - but the same help will not come up in help either VB or MSAccess!

Here's my Function so far.

Function exportspr()
DoCmd.TransferDatabase acExport, "dbase IV", NV_Springs, acTable, NVSprings, "C:\NVSprings" & Date$ & ".dbf"
End Function
 

the 3rd argument Database Name requires
A string expression that's the full name, including the path, of the database you want to use to import, export, or link data.
 
Then I get an error that the file can't be found.
 
Or more specifically

Function exportspr()
DoCmd.TransferDatabase acExport, "dbase IV", "C:\Documents and Settings\Steve Ripple\My Documents\Work\NV_Springs", acTable, NVSprings, "C:\NVSprings" & Date$ & ".dbf"
End Function

When run through a macro with a runcode Macro gives me the error: C:\Documents and Settings\Steve Ripple\My Documents\Work\NV_Springs is not a valid path. Make sure that the path name is spelled correctly....

And as far as I can see it's the correct path. It's copied directly from the Explorer window.

And again - I'm not sure if this should be a function and worked with a Macro, or somewhere else.

Thanks.
 
I've tried all sorts of combinations and the Macro Command Transderdatabase, with no luck except if I use the MSAccess Type, and then it copies the table into the database, not to a separate file. I think there is some sort of bug here. When I change the type to Dbase, I get a file not found error, not a 'wrong' file type error or some other more appropriate error. Why would it find the source file when it's exporting to Access and not when exporting to Dbase?

The transferspreadsheet works!
 
But I still can't name the output file with the date on it - Any suggestions?
 
maybe wrong here as it has been years since I've had to mess with dbase but

is the the complete path
C:\Documents and Settings\Steve Ripple\My Documents\Work\NV_Springs

or should it be
C:\Documents and Settings\Steve Ripple\My Documents\Work\NV_Springs.dbf

also you say you will be happy with txt or excell

have you looked at the transfertext or outputto methods
 
Well It should be .dbf, but when it's correct, it still does not help. For some reason the database file - the source is not readable. I've copied it to the C:\ drive with no luck - I though maybe the mydocuments folder was the problem, but it was not.

 
But I still can't name the output file with the date on it
Use the Format function instead of Date$ as "/" is an illegal character for file names:
"C:\NVSprings" & Format(Date, "yyyy-mm-dd") & ".xls"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, I thought about that too - but it still won't work. I still get the error about not finding the source file.

I've tried the OutputTo statement too, but am having trouble formating it.

I'm about to give up for now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top