I think this could be a silly question as it would seem so easy to most programmers..but what's the code for saving a particular field in Table 1 to Table 2. For instance, I want to save FirstName from Table A to FirstName in TableB.
Thanks.
It are lot of ways to do it. I'll present one of them with using recordsets.
dim rstA as recordset
dim rstB as recordset
dim strMyCriteria as string
'On the supposition that we have form with textBox PersonID strMyCriteria = me.PersonID '
set rstA=currentdb,openrecordset("Select * From TableA Where " & strMyCriteria & ";"
set rstB=currentdb,openrecordset("Select * From TableA
rstB.addnew
rstB!FirstName = rstA.FirstName 'You can update other fields like FirstName, too. rstB.update
rstA.close
rstB.close
set rstA=Nothing
set rstB=Nothing
Other way: you can create Append query (Insert SQL):
INSERT INTO TableB ( FirstName , OtherField)
SELECT TableA.FirstName , TableA.OtherField
FROM TableA
WHERE TableA.FirstName ="John";
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.