VBA/Excel/Access/Word/Access/Database Transfer
Содержание
Export database
Sub docomd()
DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\mydb.mdb", acTable, "employees", "employees"
End Sub
Exporting to a Database
Sub trasferDB()
DoCmd.TransferDatabase acExport, "Microsoft Access", _
"C:\Sales.mdb", acTable, "tblSales", "IceCreamSales"
MsgBox "Sales data exported"
End Sub
Import database
Sub transfer()
DoCmd.TransferDatabase acImport, "Microsoft Access", _
"C:\mydb.mdb", acTable, "tblI", "tblI"
End Sub
Importing Spreadsheet Data Using Code
Sub ImportSpreadsheet()
DoCmd.TransferSpreadsheet _
TransferType:=acImport, _
SpreadsheetType:=acSpreadsheetTypeExcel12, _
TableName:="Employees", _
FileName:=CurrentProject.Path & "\Customer.Xls", _
HasFieldNames:=True
End Sub
Importing Text Data Using Code
Sub ImportText()
DoCmd.TransferText _
TransferType:=acImportDelim, _
TableName:="Employees", _
FileName:=CurrentProject.Path & "\Customer.Txt"
End Sub
transfer database acExport
Private Sub cmdSales_Click()
DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\Sales.mdb", acTable, "tblSales", "ISales"
End Sub
Using the TransferDatabase Method
Sub ImportDatabase()
DoCmd.TransferDatabase _
TransferType:=acImport, _
DatabaseType:="dBASE III", _
DatabaseName:=CurrentProject.Path, _
ObjectType:=acTable, _
Source:="Employees", _
Destination:="tblCustomers", _
StructureOnly:=False
End Sub