Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    import all existing modules? (Access 2000)

    Is there any function with which to import all modules from another database without mentioning and enumerating the separate modules?

  2. #2
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: import all existing modules? (Access 2000)

    Thank you !!!

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: import all existing modules? (Access 2000)

    I somehow cannot import the modules since i get the error
    "opreation is not supported for this type of object" pointing to the line For Each doc In ctr
    I did refer to DAO 3.6.
    Did i do something wrong?
    Below is your code as follows

    Dim dbs As DAO.Database
    Dim ctr As DAO.Container
    Dim doc As DAO.Document
    Dim strDatabase As String
    Set dbs = OpenDatabase(GPath)
    Set ctr = dbs.Containers("Modules")
    For Each doc In ctr
    DoCmd.TransferDatabase acImport, "Microsoft Access", GPath, acModule, doc.Name, doc.Name
    Next doc




    Best regards

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

    Re: import all existing modules? (Access 2000)

    Code corrected by HansV

    You can import all modules interactely, the Import Objects dialog has a Select All options.

    If you want to do this in code, you can use the Modules container in DAO. You must have a reference to the Microsoft DAO 3.6 Object Library.

    Sub ImportModules(strDatabaseName As String)
    Dim dbs As DAO.Database
    Dim ctr As DAO.Container
    Dim doc As DAO.Document

    On Error GoTo ErrHandler

    Set dbs = OpenDatabase(strDatabaseName)
    Set ctr = dbs.Containers("Modules")
    For Each doc In ctr.Documents
    DoCmd.TransferDatabase acImport, "Microsoft Access", strDatabaseName, acModule, doc.Name, doc.Name
    Next doc

    ExitHandler:
    On Error Resume Next
    Set doc = Nothing
    Set ctr = Nothing
    dbs.Close
    Set dbs = Nothing
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    Call this procedure in the form

    ImportModules "C:AccessTest.mdb"

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

    Re: import all existing modules? (Access 2000)

    Please accept my apologies, there were several errors in the code I posted earlier (I tested it, then changed a few things without testing again <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>)

    I have corrected the code in my previous reply; it should work OK now. <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>

Posting Permissions

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