Results 1 to 2 of 2

Thread: [RESOLVED] Creating a new table with DAO

  1. #1

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    678

    Resolved [RESOLVED] Creating a new table with DAO

    It's been over 20 years since I needed to add a table from VB6 code. I found some articles on how to do it but I'm missing something.

    Ok so the program does the following
    1. enter the name of the new table in a txt box - in form_load
    2. Open the database using DAO - from form_load calls OpenDatabase procedure
    3. Add the new table - from form_load calls the AddTable procedure
    4. Close the database - from form_load calls the CloseDatabase Procedure.

    In AddTable, here's the beginning code

    Code:
    Private Sub AddTable(sCategory As String)'Purpose:   Create a table using DAO.
    Dim db  As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
        
        
        'Initialize the Contractor table.
        Set db = CurrentDb
        Set tdf = db.CreateTableDef("tbl" & sCategory)
    I can't get past the Set db statement. shown in red. I am not sure what I need.

    Thanks

  2. #2

    Thread Starter
    Fanatic Member AccessShell's Avatar
    Join Date
    Oct 2013
    Posts
    678

    Re: Creating a new table with DAO

    OK, as usual, within a few minutes after posting, I found the answer. It works now.

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