Results 1 to 9 of 9

Thread: ACCESS '97: How To: Copy Table to new Database and Format column widths [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Resolved 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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    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:
    1. Dim Db As DAO.Database 'Easier with DAO although older
    2.   Set Db = DbEngine.CreateDatabase("C:\MyDatabase.mdb",dbLangGeneral)
    3.   Dim Td As DAO.TableDef
    4.   Set Td = Db.CreateTableDef("MyTable")
    5.   Dim Fd As DAO.Field
    6.   Set Fd = Td.CreateField("MyField")
    7.   Fd.Type = dbtext
    8.   Fd.Size = 50
    9.   Td.Fields.Append Fd
    10.   Set Fd = Noting
    11.   Db.TableDefs.Append Td
    12.   Set Td = Nothing
    13.   Db.Close
    14.   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

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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

  7. #7
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: ACCESS '97: How To: Copy Table to new Database and Format column widths ???

    Try updating the tabledefs by

    VB Code:
    1. Mydb.TableDefs.Refresh

    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

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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

  9. #9
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    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
  •  



Click Here to Expand Forum to Full Width