Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    import with ADO (Access 2000)

    How to import all the forms from external database

    I want to import all the forms available in an external database with the help of ADO. Actually,the same as when i select FileGetExternalDataSelectAllFormsImport. Otherwise i use the command Transferdtabase,but then i have to import each form separately.
    Any help?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: import with ADO (Access 2000)

    Is there a reason you need to do this with code? DAO is easier for this purpose, but I can't think of a good reason not to do it from the UI instead ... unless you're trying to create a sort of database template.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: import with ADO (Access 2000)

    Thank you for your reply.I need to do it with a code.Can i do it with DAO?Is it possible?I mean to import all the forms from
    an external database without paying attention to their number ? Or it is not possible?
    Thank you once again
    regards

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: import with ADO (Access 2000)

    It's possible either way. With DAO, forms are members of the Forms collection of the Database object. With ADO, they're members of the AllForms collection of the CurrentProject object. Here's a code routine (Access 2000 and higher only) that will import all the form object from another Access 2000 database into the current one, but be warned that this is not a fast process except on a very fast machine.

    <pre>Function ImportAllForms(ByVal strDBName As String)
    <font color=448800>'created by Charlotte Foust 9/23/2001 </font color=448800>
    Dim appAccess As Access.Application
    Dim frm As AccessObject
    On Error GoTo Proc_err

    <font color=448800> 'open a new instance of Access</font color=448800>
    Set appAccess = New Access.Application
    <font color=448800>'open the passed database name, not exclusive</font color=448800>
    appAccess.OpenCurrentDatabase strDBName, False

    <font color=448800>'Loop through the AllForms collection of the database</font color=448800>
    For Each frm In appAccess.CurrentProject.AllForms

    <font color=448800>'import each form into the current database</font color=448800>
    DoCmd.TransferDatabase TransferType:=acImport, _
    DatabaseType:="Microsoft Access", _
    DatabaseName:=strDBName, _
    ObjectType:=acForm, _
    Source:=frm.name, _
    Destination:=frm.name & "New"
    Next frm <font color=448800>' In appAccess.CurrentProject.AllForms</font color=448800>

    Proc_exit:
    On Error Resume Next
    <font color=448800>'cleanup and exit</font color=448800>
    appAccess.CloseCurrentDatabase
    Set appAccess = Nothing
    Exit Function
    Proc_err:
    MsgBox Err.Number & "--" & Err.Description
    Resume Proc_exit
    End Function <font color=448800>'ImportAllForms(ByVal strDBName As String)</font color=448800></pre>

    Charlotte

Posting Permissions

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