Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    copy similar tables (Access 2000)

    I am copying blank tables to another database.Is it possible to avoid the enumeration of the different tables and to export all the tables having the same pefix as
    DoCmd.TransferDatabase acExport, "Microsoft Access", appath, acTable, "studentsRu", "studentsRu", True
    DoCmd.TransferDatabase acExport, "Microsoft Access", appath, acTable, "studentsSo", "studentsSo", True
    DoCmd.TransferDatabase acExport, "Microsoft Access", appath, acTable, "studentsFi", "studentsFi", True
    etc etc, i have a lot more
    My question is, can i do the command with one line ?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: copy similar tables (Access 2000)

    Hi there

    Sorry I can't give you a full code but here is a table transfer function

    It appears to make a full listing of the tables in the current database and then later makes a transfer list of all the tables with a MSys prefix you may want to change this code to fit your needs
    Jerry

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

    Re: copy similar tables (Access 2000)

    No, you can't do that with one line.
    Do you want to export all tables whose name begins with "students"? If so, you could use

    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Set dbs = CurrentDb
    For Each tdf In dbs.TableDefs
    If Left(tdf.Name, 8) = "students" Then
    DoCmd.TransferDatabase acExport, "Microsoft Access", appath, acTable, tdf.Name, tdf.Name, True
    End If
    Next tdf
    Set tdf = Nothing
    Set dbs = Nothing

Posting Permissions

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