CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2000
    Posts
    1

    Update Access97 Table with Fields From Another Database

    Can someone point me in the right direction? I have an Access97 database table that I need to update only certain fields in certain records from another Access database. Adding/Deleting records between the two is not a player. Only updating certain fields. I do not have VB but am hoping I can do this with VBA. If someone can kickstart me, I'll be off and running. Thanks!


  2. #2
    Guest

    Re: Update Access97 Table with Fields From Another Database

    Create 2 recordset (DAO or ADO), use data from one of them to update the second one using appropriate criterias.
    Vlad


  3. #3
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Update Access97 Table with Fields From Another Database

    I'm not 100% sure, might just have some little mistakes (don't have acces around), but i've done this before, should look about something like this:


    ' this example will get the name of user with id 15 out table1 and modify another record in table2
    dim db as database
    ' rst1 is the input table
    ' rst2 the output table
    dim rst1 as recordset
    dim rst2 as recordset
    dim strName as string

    set db = currentdb
    set rst1 = db.openrecordset("table1")
    set rst2 = db.openrecordset("table2")

    rst1.movenext
    with rst1
    do while not( rst1.eof )
    if .fields!uID = 15 then
    strName = .fields!Name
    end if
    loop
    end with

    rst2.movefirst
    with rst2
    do while not( rst2.eof )
    if .fields!uID = 15 then
    .fields!Name = strName
    end if
    loop
    end with

    ' close recordsets and database refferences
    rst1.close
    rst2.close
    db = nothing




    Tom Cannaerts
    [email protected]

    The best way to escape a problem, is to solve it.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured