Transfer data from .dbf file into .mdb Table
Transfer data from .dbf file into .mdb Table
API Declarations
Public InRs As New ADODB.Recordset
Public OutCon As New ADODB.Connection
Public OutRs As New ADODB.Recordset
'Need to have an Employees.mdb (Access database with Employees table to start
'Need to have a te
Rate Transfer data from .dbf file into .mdb Table
(1(1 Vote))
Private Sub TransferDBF2MDB()
Dim StrPath As String
StrPath = "XXXXX.dbf" 'Your dbf File
'Point connection to database
InCon.Open "Driver={Microsoft dBASE Driver(*.dbf)};DriverID=277;Dbp=.\;"
OutCon.Open "Driver={Microsoft Access Driver(*.mdb)};Dbq=.\XXXSX.mdb;Uid=Admin;Pwd=;"
'Point Recordset to connection, note that "Temp" is the table name in XXXXX.mdb
InRs.Open "XXXXX.dbf", InCon, adOpenDynamic, adLockOptimistic, adCmdTable
OutRs.Open "Temp", OutCon, adOpenDynamic, adLockOptimistic, adCmdTable
'Read input database until EOF
Do Until InRs.EOF
OutRs.AddNew 'Insert a new record
'copy data from input record into output record
OutRs!Field0 = InRs.Fields(0)
OutRs!Field1 = InRs.Fields(1)
OutRs!Field2 = InRs.Fields(2) '...and so on
OutRs.Update
InRs.MoveNext
Loop
'Don't Forget to Close both files
Inrs.Close
InCon.Close
Set InCon = Nothing
Set InRs = Nothing
OutRs.Close
OutCon.Close
Set OutRs = Nothing
Set OutCon = Nothing
'Delete the dbf file
Kill StrPath 'Kill "XXXXX.dbf"
End Sub
Transfer data from .dbf file into .mdb Table Comments
No comments yet — be the first to post one!
Post a Comment