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 Dbase III file into access 2002-2003

Status
Not open for further replies.

kdart301

IS-IT--Management
Apr 4, 2006
8
US
Hi,
I would like to import a Dbase file into my access database using the api browser. I have all of the code and the dialog opens and I can select my file. The problem is when I try a domcd transferdatabase, I can't seem to get it right. The error is:

run time error 3044
'C:\data\paradise.DBF' 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.

Function:

Function TestIt()
Dim strFilter As String
Dim strInputFileName As String
Dim lngFlags As Long

strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.XLS")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strInputFileName = ahtCommonFileOpenSave( _
filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
Debug.Print strInputFileName
DoCmd.TransferDatabase acImport, "DBase III", strInputFileName, acTable, False
End Function


Thanks in advance.....
Ken
 
Replace this:
DoCmd.TransferDatabase acImport, "DBase III", strInputFileName, acTable, False
with this:
Dim strDir As String, strFile As String
strDir = Left(strInputFileName, InStrRev(strInputFileName, "\") - 1)
strFile = Mid(strInputFileName, InStrRev(strInputFileName, "\") + 1)
DoCmd.TransferDatabase acImport, "DBase III", strDir, acTable, strFile, ,False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

Sorry took so long. I did what you suggested and received an error:

Run-time error '2006':
The object name " you entered doesn't follow Microsoft Access object-nameing rules.

Thanks...
 
And this ?
DoCmd.TransferDatabase acImport, "DBase III", strDir, acTable, strFile, "your table name here",False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

It works and I feel dumb.

Thanks, saw the extra comma and forgot to place the table name. I appreciate your help!.


Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top