Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    copy database (Access 2000)

    I find myself in database A. I want to copy a query from Database B, rename the query toQueryNew aqnd send it to Database C.
    Is it posssible ?
    P.S. i mean sending it by code

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

    Re: copy database (Access 2000)

    It depends on exactly what you want to do. From the database window, you can import a query from another database, change the name of the imported query and then export it to another database with whatever name you choose.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy database (Access 2000)

    I want it to do it automatically by code, since this process repeats itslef with me many times.I need a code something like
    FileCopy([img]/forums/images/smilies/cool.gif[/img]....
    Is it possible ?

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

    Re: copy database (Access 2000)

    But queries are not files, they are objects in a database. What kind of queries are these, and why are you copying them around like this? There must be a simpler approach.
    Charlotte

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy database (Access 2000)

    CopyFile may be not the right word, maybe copy object,but what i need to know is can i copy a query from Database B , rename it and send it to Database C ?
    Access is so powerful, perhaps there exists a possibility to copy a query through code from one database to another.

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

    Re: copy database (Access 2000)

    It might be useful to copy a query from the current database to another database, but to copy from Database B to Database C is unusual. If Database B doesn't have a startup form, you could try this:

    Sub CopyQuery(DbSource As String, QrySource As String, _
    DbTarget As String, QryTarget As String)
    Dim objApp As New Access.Application
    On Error GoTo ErrHandler
    DoCmd.Echo False
    objApp.OpenCurrentDatabase DbSource
    objApp.DoCmd.TransferDatabase acExport, "Microsoft Access", _
    DbTarget, acQuery, QrySource, QryTarget

    ExitHandler:
    On Error Resume Next
    objApp.Quit
    Set objApp = Nothing
    DoCmd.Echo True
    Exit Sub

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

    Call it like this:

    CopyQuery "C:AccessdbA.mdb", "QueryA", "C:AccessdbB.mdb", "QueryB"

Posting Permissions

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