xanders said:
Do somebody have some code (syntaxis) to copy (export)
tables from database A to database B.
At the moment I control it manualy.
I do not mean to link the table!
Here's some code that will create the second database, then fill it with the
tables and data:
Public Function CreateWebDatabase()
On Error Resume Next
Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim strPath As String
strPath = "C:\FolderName\WebDB.mdb"
' Get default Workspace.
Set ws = DBEngine.Workspaces(0)
' Make sure there isn't already a file with the name of
' the new database.
If Dir(strPath) <> "" Then Kill strPath
' Create a new database
Set db = ws.CreateDatabase(strPath, dbLangGeneral)
db.Close
End Function
Public Function WebDB()
On Error Resume Next
Call CreateWebDatabase
Dim Response As Integer
Dim strPath As String
Dim strSQL As String
Dim db As DAO.Database
Dim ws As DAO.Workspace
Dim fInTrans As Boolean
'On Error GoTo Err_RollbackDB
fInTrans = False
Set ws = DBEngine.Workspaces(0)
Set db = ws.Databases(0)
strPath = "C:\FolderName\WebDB.mdb"
BeginTrans
On Error GoTo Err_RollbackDB
fInTrans = True
strSQL = "SELECT tblCountry.* INTO tblCountry IN '" & strPath & "' FROM
tblCountry"
db.Execute strSQL
strSQL = "SELECT tblSubdivision.* INTO tblSubdivision IN '" & strPath &
"' FROM tblSubdivision"
db.Execute strSQL
strSQL = "SELECT tblLot.* INTO tblLot IN '" & strPath & "' FROM tblLot"
db.Execute strSQL
ws.CommitTrans ' Commit changes
RollbackDB_Exit:
DoCmd.Hourglass False
Set db = Nothing
Set ws = Nothing
Exit Function
Err_RollbackDB:
' MsgBox "There has been an error " & strPath & " was not created",
vbCritical, "ERROR"
If fInTrans Then
ws.Rollback
End If
Resume RollbackDB_Exit
End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access