Click to See Complete Forum and Search --> : Update Access97 Table with Fields From Another Database
KJanis
February 28th, 2000, 10:36 AM
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!
February 28th, 2000, 11:47 AM
Create 2 recordset (DAO or ADO), use data from one of them to update the second one using appropriate criterias.
Vlad
Cakkie
February 28th, 2000, 11:50 AM
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
slisse@planetinternet.be
The best way to escape a problem, is to solve it.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.