ADOX added table availability in Access

Discussion in 'AutoCAD' started by John Goodfellow, Apr 27, 2004.

  1. I'm getting an Access Application object error after creating a table in
    ADOX. Looks like Access needs to be told to recognize the new table,
    'Test2'. When and how should this be done? Didn't find clear answer
    searching MSDN or web.

    1. Create a table (e.g. 'Test2') in an Access .Mdb via ADOX in VBA sub
    Dim oConn As New ADODB.Connection
    Dim oCatalog As New ADOX.Catalog
    Dim oTable As New ADOX.Table
    Dim oCol As New ADOX.Column
    ' connection string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    <full path to .Mdb>
    ' set Catalog connection to .Mdb
    ' set up columns in Column objects
    ' append Column objects to Table object
    ' append Table object to Catalog object
    ' everything looks OK in debugger windows
    ' close all objects & set = Nothing

    2. Create an Access Application object in later VBA sub
    Dim moAccess As Access.Application ' MS Access application object
    Set moAccess = CreateObject("Access.Application")
    moAccess.OpenCurrentDatabase <full path to .Mdb>

    3. Use DoCmd.RunMacro in later VBA sub to run a Access macro which runs a
    series of Access queries.
    moAccess.DoCmd.RunMacro sMacroName ' run the Access macro

    4. First Access query run via the macro returns error message:
    "The Microsoft Jet database engine cannot find the input table or query
    'Test2' ..."
    In the Access database window, Table 'Test2' is not visible until the window
    is refreshed (F5). After that, the query will run.

    Thanks
    John Goodfellow
     
    John Goodfellow, Apr 27, 2004
    #1
  2. That is a problem with the Jet cache.
    If you use the same connection object for both operations you should
    experience no problem
    Why not use ADO to open the table just created with ADOX ?
     
    Jorge Jimenez, Apr 27, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.