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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing a .DBF File to Access

Status
Not open for further replies.

osera

Technical User
May 15, 2006
35
US
Good evening.

Once again, I find myself turning here for assistance after the 'Help' function in Access turns out to be anything but.

Here's my situation.

I'm pulling a data file off a government website. The file saves as a .DBF document (FileName.DBF) and that's pretty much the only option. Saving it as a .txt file leaves me with a document that Access can't import.

What I'd like to have is a VBA string that will instruct the database to import the file to a table so my users can import with the click of a button rather than go through the arduous task of File>Get External Data>Import>etc.

I'm pretty sure I need the DoCmd.TransferDatabase function, but I can't figure out how to get the parameters to work since I'm only importing a .DBF document, not a table from an actual database.

Any assistance will be greatly appreciated.
 
Hi,

Try the below:

Regards

Kevin


With Literals:

DoCmd.TransferDatabase acImport,"dbase IV", "C:\MyDBFs\", acTable, DBFFileName.DBF","MyAccessTableName"

With Variables:

SourcePath="C:\MyDBFs"
DBFName = "MydbaseFile.DBF"
AccessTableName = "tblToPutIn"

DoCmd.TransferDatabase acImport,"dbaseIV",
SourcePath, acTable, DBFName, AccessTableName
 
As always, I can find my answers here. Thanks, Kevin, works perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top