C
Carriolan Shinobi
Hi Ifound this code on the web for seting up a new database and then
exporting tables and text to it. However the VB editor highlights the
DIM statements in red. How can I fix this please
Sub exportdata()
Dim ws As Workspace
Dim db As Database
Dim LFilename As String
'Get default Workspace
Set ws = DBEngine.Workspaces(0)
'Path and file name for new mdb file
LFilename = "c:\NewDB.mdb"
'Make sure there isn't already a file with the name of the new
database
If Dir(LFilename) <> "" Then Kill LFilename
'Create a new mdb file
Set db = ws.CreateDatabase(LFilename, dbLangGeneral)
'For lookup tables, export both table definition and data to
new mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access",
LFilename, acTable, "Lookup Table1", "Lookup Table1", False
'For data entry tables, export only table definition to new
mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access",
LFilename, acTable, "DataEntry Table1", "DataEntry Table1", True
db.Close
Set db = Nothing
End Sub
Thanks Carriolan
exporting tables and text to it. However the VB editor highlights the
DIM statements in red. How can I fix this please
Sub exportdata()
Dim ws As Workspace
Dim db As Database
Dim LFilename As String
'Get default Workspace
Set ws = DBEngine.Workspaces(0)
'Path and file name for new mdb file
LFilename = "c:\NewDB.mdb"
'Make sure there isn't already a file with the name of the new
database
If Dir(LFilename) <> "" Then Kill LFilename
'Create a new mdb file
Set db = ws.CreateDatabase(LFilename, dbLangGeneral)
'For lookup tables, export both table definition and data to
new mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access",
LFilename, acTable, "Lookup Table1", "Lookup Table1", False
'For data entry tables, export only table definition to new
mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access",
LFilename, acTable, "DataEntry Table1", "DataEntry Table1", True
db.Close
Set db = Nothing
End Sub
Thanks Carriolan