Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    export all tables (Access 2000)

    I have a function to export all tables.I call it by clicking ImportAllTables "C:bebe.mdb", "secret". On that basis i built a function to export all tables. But when i click ExportAllTables "C:bebeNew.mdb", "secret", nothing happens and no tables are exported. Why is it so ? Below are both functions :
    Public Function ImportAllTables(DBName As String, strPassword As String) As Boolean
    ' call it so : ImportAllTables "C:bebe.mdb", "secret"
    Dim FrontDB As Database, BackDB As Database, Tbl As DAO.TableDef
    Set FrontDB = CurrentDb
    Set BackDB = OpenDatabase(DBName, True, False, ";PWD=" & strPassword)
    For Each Tbl In BackDB.TableDefs
    If Tbl.Attributes = 0 Then
    DoCmd.TransferDatabase acImport, "Microsoft Access", BackDB.Name, acTable, Tbl.Name, Tbl.Name
    End If
    Next
    BackDB.Close
    FrontDB.Close
    End Function

    Public Function ExportAllTables(DBName As String, strPassword As String) As Boolean
    Dim FrontDB As Database, BackDB As Database, Tbl As DAO.TableDef
    Set FrontDB = CurrentDb
    Set BackDB = OpenDatabase(DBName, True, False, ";PWD=" & strPassword)
    For Each Tbl In BackDB.TableDefs
    If Tbl.Attributes = 0 Then
    DoCmd.TransferDatabase acExport, "Microsoft Access", BackDB.Name, acTable, Tbl.Name, Tbl.Name
    End If
    Next
    BackDB.Close
    FrontDB.Close
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: export all tables (Access 2000)

    Obviously, if you want to export tables from the current database, you must loop through the tables of the current database, not those of the target database. So you must use

    For Each Tbl In FrontDB.TableDefs

  3. #3
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: export all tables (Access 2000)

    It is fine now thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •