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

How to save just a table from Access to a new database 3

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I am using Access 2000 and Windows XP in this example. What I have is a database (Daily.mdb) with 1 table (Data) and 1 form (Input). This 1 table and 1 form are used to create 1 totally new table (NewData) based on user input. This new table (NewData) then becomes part of the (Daily.mdb) database. Using some VBA code I would like to save just this table (NewData) into a totally new database (Today.mdb) then I will delete this (NewData) table from (Daily.mdb) Is this at all possible, any suggestions would be greatly appreciated. Thank you for your support.
 
Have a look at the DoCmd.CopyObject method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How are ya vamoose . . .

. . . or perhaps the [blue]TransferDatabase Method[/blue] (transfer the table only).

Calvin.gif
See Ya! . . . . . .
 
And even SQL

strExtDBase = "C:\Docs And Setts\joe\Today.mdb"

SQL = "SELECT * " & _
"INTO NewData" & _
"IN '" & strExtDBase & "' " & _
"From NewData"


CurrentProject.Connection.Execute SQL,,adExecuteNoRecords
 
Thank you very much for the suggestions. I have this working somewhat. This is the code I am currently using to copy the table (NewData) from (Daily.mdb) to (Today.mdb)
The only glitch so far is that the database (Today.mdb) must already exist in order for this to execute properly.

DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\Temp\Today.mdb", acTable, "NewData", NewData", False

Is it possible to have this line of code first create the database C:\Temp\Today.mdb or is this a seperate command alltogether which must be ran first ?

Thank you all.
 
DBEngine.CreateDatabase "C:\Temp\Today.mdb", dbLangGeneral
DoCmd ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top