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

Importing dBase IV and Excel files in Access through VB 3

Status
Not open for further replies.

damotwani

MIS
May 31, 2003
19
0
0
IN
Hi,

How I import dBase IV and Excel files into Access? I will really appreciate it if someone can give me the code for this.

Thanks,

Dheeraj
 
- TransferSpreadsheet for Excel
- TransferDatabase for Dbf (Dbase)

Look in the help file for some easy to use examples.


Patrick.
 
Hi,

Thanks for the lead. But I get this error when I try to use TransferDatabase:

Object Required

what should I do?

D
 
What parameters have you given TransferDatabase. Please post the code.

Also:
Have you looked at the VBA help file. It contains an excellent example of both commands.


Patrick.
 
Thanks for the reply Patrick.

Here is what I am trying to do. The path of the dBase IV file which is to be imported is in a textbox named 'Cmbhavfile'. I am using the following code to import te file into a table in the Access Database:

Private Sub Next_Click()

Dim cnn As New ADODB.Connection

cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\V Care\bhav.mdb;Persist Security Info=False"

DoCmd.TransferDatabase acImport, "dBbase IV", Cmbhavfile.text, acTable, Cmbhavfile.text, "D:\V Care\bhav.mdb", False, False

End Sub



I am using Access 2000, VB 6.0 and Windows XP.

The help file had an example that showed how to transfer an Access Database. Also I am trying to get the file path from a text box. I hope I can do that.

Thanks,

D
 

Try this:
DoCmd.TransferDatabase acImport, "dBbase IV", PATHTOFILE, acTable, DBFFILENAME, "D:\V Care\bhav.mdb", False, False

patrick
 
AHA!

So I don't get the "Object Required" error anymore. So you have star for that (I was so tired of seeing the same error... :) thanks!)

But now we a different one.

I get this error:

Run-time error: 91
Object Variable or With Block Variable not set.

when I run this code:



Private Sub Next_Click()

Dim cnn As ADODB.Connection

cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\V Care\Project\bhav1.mdb;Persist Security Info=False"

DoCmd.TransferDatabase acImport, "dBbase IV", "D:\V Care\Project\cmbhav.dbf", acTable, cmbhav, "D:\V Care\Project\bhav1.mdb", False, False

End Sub



Where: "D:\V Care\Project\cmbhav.dbf" is the dbf file
cmbhav is the dbf table to be imported
"D:\V Care\Project\bhav1.mdb" is the target DB



Hope you can help me with this!

Thanks,

Dheeraj


 
Try this:

DoCmd.TransferDatabase acImport, "dBbase IV", "D:\V Care\Project\", acTable, cmbhav, "D:\V Care\Project\bhav1.mdb", False, False


Patrick.

PATHTOFILE is just the path, not the file itself.

Patrick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top