Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Unanswered: append query in two different databases

    Hy I'm Antonio from Italy. I need help to create a query (SQL) in MS Access
    2003 that appends data in two identical tables named "tblUsers" stored, the
    first (A) on local database logon.mdb and the second in another local
    database (B) stored in "E:\utenti\logon.mdb", but i need to append only the
    new records of database A that doesn't exist in database B. Someone cab help
    me with the exact expression and grammar to do this?
    many thanks everybody !! ;-)

    the two databases names is the same: logon.mdb
    the two tables names are the same: tblUsers.
    this is the query i wrote, but it doesn0t work: what is bad?
    The query, without the clause WHERE, works fine. but with that clause makes
    an error "incorrect database name" (strange). But without that clause it
    still append all records and not only tha are new in he master.
    INSERT INTO tblUsers ( UID, PWD, COMPARTIMENTO, UFFDOGANE, COGNOME, NOME,
    INDIRIZZO, CAP, COMUNE, PROVINCIA, TELEFONO, CELLULARE, TELEFAX, EMAIL, WWW,
    ID, ADMIN, ENABLED, YEARENABLEDDATE, MONTHENABLEDDATE, DAYENABLEDDATE,
    COD_Questionario ) IN 'E:\Documenti Antonio\Siti Web\CoNaSpDo\FAD\FAD\
    riservato001\_private\logon.mdb'
    SELECT tblUsers.UID, tblUsers.PWD, tblUsers.COMPARTIMENTO, tblUsers.UFFDOGANE,
    tblUsers.COGNOME, tblUsers.NOME, tblUsers.INDIRIZZO, tblUsers.CAP, tblUsers.
    COMUNE, tblUsers.PROVINCIA, tblUsers.TELEFONO, tblUsers.CELLULARE, tblUsers.
    TELEFAX, tblUsers.EMAIL, tblUsers.WWW, tblUsers.ID, tblUsers.ADMIN, tblUsers.
    ENABLED, tblUsers.YEARENABLEDDATE, tblUsers.MONTHENABLEDDATE, tblUsers.
    DAYENABLEDDATE, tblUsers.COD_Questionario
    FROM tblUsers
    WHERE tblUsers.UID<>[E:\Documenti Antonio\Siti Web\CoNaSpDo\FAD\FAD\
    riservato001\_private\logon.mdb].[tblUsers.UID];

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You could dynamically attach the table from the external database, execute your query on it then detach it. Another possibility would be to open that external database (Set dbs = OpenDatabase(... etc. ). Personally I prefer the first solution.

    Have a nice day!

Posting Permissions

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