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

Error when trying to use TransferDatabase in VB

Status
Not open for further replies.

damotwani

MIS
May 31, 2003
19
IN
Hi,

I am trying to import a dbase IV file into table in Access using the TransferDatabase command.


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,
 
You just declared cnn as a variable and immediately started using it. I assume you will have to create a connection to the database, but on the line immediately following you use the DoCmd, which doesn't need any sort of object variable to run anyway.

Solution: take out that part about cnn. If you need to open the Access database (if it isn't already open) and import the dBase file, do it a different way than you're doing now.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top