Cannot Define Tables after Importation from Passworded Access DB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • monbois
    New Member
    • Apr 2007
    • 3

    Cannot Define Tables after Importation from Passworded Access DB

    In my MS Access VBA sub-routine, after having identified an external database as having a password, by database retrieves the password from a table before importing the Questions and Text tables from that external database.

    The following variables are assigned before the code is executed:

    strLXRpthQdb = Name & Path of External Database
    strPW = External Database's Password


    Code:
        Dim tdf As DAO.TableDef
        Dim appacc As Object
        Dim db As Database
        Set appacc = CreateObject("Access.Application")
    
        With appacc
            .AutomationSecurity = 1
            .OpenCurrentDatabase strLXRpthQdb, False, strPW
        End With
    
    
        i = 0
    
    '   loop to import Questions & Text tables
    '   -------------------------------------------------------
        Do Until (i = 2)
    
            i = (i + 1)
    
            If (i = 1) Then
                strTbl = "Questions"
            Else
                strTbl = "Text"
            End If
    
            For Each tdf In appacc.CurrentDb.TableDefs
                If tdf.NAME = strTbl Then
                    appacc.DoCmd.CopyObject strDBNpth, , acTable, tdf.NAME
                Else
    '               ----- do nothing -----
                End If
            Next tdf
        Loop
    
        appacc.CloseCurrentDatabase
        Set appacc = Nothing
    
    '   NEITHER OF THESE WORKS!!!
    '   -------------------------------------------------------
        CurrentDb.TableDefs.Refresh
        Application.RefreshDatabaseWindow

    As indicated in the VBA notes, neither of the following 'refresh' procedures works.

    As a result, I can't do anything with the tables I've just imported. Importing via regular 'TransferDataba se' seems to automatically refresh the table definitions. I've tried inserting 'db = CurrentDb' as I've seen suggested, but still no dice.

    ANY suggestions would be appreciated!

    Thanks!
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    I am not that familiar with the process you try to implement, but can you confirm that the objects are actually copied at all to the intended destination?

    Comment

    • monbois
      New Member
      • Apr 2007
      • 3

      #3
      Yes. Once the VBA stops it looks like the imported tables are not there. However, if I click on the queries tab (Access 2003) and then back to the tables tab, the newly imported tables show up.

      They're definitely being imported, but the database just doesn't know it. It's very frustrating.

      Hope you can help.

      Thanks.

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        I see.

        The question is if its merely a display problem or a functional problem. Can you work with the imported objects through code?

        Or is the problem more that you want the display to be updated immediately? You haven't really described what the main purpose is, i.e. what should happen after the import.

        Comment

        Working...