|
-
Jul 26th, 2005, 04:24 PM
#1
Thread Starter
Frenzied Member
ACCESS '97: How To: Copy Table to new Database and Format column widths [RESOLVED]
Esteemed Forum Participants and Lurkers:
===============================
Access '97
Well, Great Success! I can now retrieve my data from the corporate Oracle Server and put it into 4 tables in the local Current Database.
(1) How can I copy one of the tables (G_Table) into a clean access database (G_Data.mdb)? (it goes in folder "\\g0ghq\Work\DB\")
(2) How can I programmatically format the displayed column widths for the table? (4 columns)
Thank you for your gracious comments, suggestions, and assistance.
Last edited by Webtest; Jul 27th, 2005 at 02:23 PM.
Reason: [RESOLVED]
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 26th, 2005, 04:36 PM
#2
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
Its me agian. Lets see how bad I can screw this simple one up. 
You can copy database objects with this...
VB Code:
Application.DoCmd.CopyObject "DestinationDatabase", "NewName", acTable, "Table1"
How do you mean format the columns? In Table view in Access?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 26th, 2005, 04:37 PM
#3
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
Arrg! Started already. I see that your originating db is Oracle or already in Access?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 27th, 2005, 07:31 AM
#4
Thread Starter
Frenzied Member
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
RobDog ... the GREAT Competition Deep Sea Fisherman!
Forget about Oracle ... I'm already done with that ... I've got that part working GREAT! (Well, it's slower than molasses, but it works) My tables that I'm working with are all now local tables in the Access '97 Master database.
(1) I saw the DoCmd.CopyObject function and played with it, but it requires a valid existing destination database. So I guess that is my real question ... the various steps reqired to create a NEW database out on a shared network drive in preparation for copying the table. The 'reference' book I have stinks and is nearly useless. I'm getting lost in ADODB, ADOX, Catalogs(?), etc. I just want to spin off a clean database with a copy of one of my tables that I create dynamically (programatically).
(2) Yes, I want to automatically set up the NEW (Slave) database Table (created programatically) so that when the user opens it for viewing and editing, the column widths are set reasonably. Any ideas on that?
Thanks for your gracious assistance. I really need to find a good comprehensive Access book.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 27th, 2005, 07:53 AM
#5
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
Mut have a reference to "Microsoft DAO 3.6 Object Library"
VB Code:
Dim Db As DAO.Database 'Easier with DAO although older
Set Db = DbEngine.CreateDatabase("C:\MyDatabase.mdb",dbLangGeneral)
Dim Td As DAO.TableDef
Set Td = Db.CreateTableDef("MyTable")
Dim Fd As DAO.Field
Set Fd = Td.CreateField("MyField")
Fd.Type = dbtext
Fd.Size = 50
Td.Fields.Append Fd
Set Fd = Noting
Db.TableDefs.Append Td
Set Td = Nothing
Db.Close
Set Db = Nothing
Last edited by RobDog888; Jul 27th, 2005 at 07:37 PM.
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Jul 27th, 2005, 08:52 AM
#6
Thread Starter
Frenzied Member
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
Thanks Danny ... I got it working from your example. Here is my code:
Code:
Sub Test_Transfer_DB()
Dim myDB As DAO.Database 'Do NOT use 'New' - it is not valid???
'Define and Create the new Database for the table
Set myDB = DBEngine.CreateDatabase("C:\Test\MyDatabase.mdb", dbLangGeneral)
'Copy the existing SRC table into the new database as DEST table
DoCmd.CopyObject myDB.Name, "DEST_TEST_EXTRACT", acTable, "SRC_TEST_EXTRACT"
'Clean House
myDB.Close
Set myDB = Nothing
End Sub
I tried to use "TransferDatabase" to create a Linked Table, but it keeps complaining that it can't find the SOURCE table (it's in the Current Database) ...
Code:
'DoCmd.TransferDatabase acLink, "Microsoft Access", myDB.Name, acTable, "TEST_EXTRACT", "DEST_TEST_EXTRACT"
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 27th, 2005, 09:04 AM
#7
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
Try updating the tabledefs by
Also it would be better to replace
myDB.Name from the TransferDatabase with the actual filepath originally used in the creation of the database..
I really need to find a good comprehensive Access book
Last edited by RobDog888; Jul 27th, 2005 at 07:37 PM.
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Jul 27th, 2005, 02:22 PM
#8
Thread Starter
Frenzied Member
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???
Here's the answer to the "Column Width" part of the question. You have to open the datasheet and then dynamically set the width. Find the "Resizing columns" section:
You Can Do That with Datasheets?
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Jul 27th, 2005, 03:40 PM
#9
Re: ACCESS '97: How To: Copy Table to new Database and Format column widths [RESOLVED]
When I refered to the Size it was actually the field size of the text field created in the table in my example and not the size of the column..
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|