• copy database (Access 2000)

    Author
    Topic
    #420560

    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

    Viewing 0 reply threads
    Author
    Replies
    • #952674

      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.

      • #952676

        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(….
        Is it possible ?

        • #952678

          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.

          • #952679

            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.

            • #952687

              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”

    Viewing 0 reply threads
    Reply To: copy database (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: