Update table with values from Subform (Unbound/Query)? (1 Viewer)

Heatshiver

Registered User.
Local time
Today, 06:51
Joined
Dec 23, 2011
Messages
263
I have a complicated form that has about 3 subforms on it. Each subform is based off a calculated query, which in itself consists of several other queries. I need to have those calculated values be committed to an existing table. I understand that storing calculated fields is not practical, but it is necessary for now. There are also at least two unbound fields that also need to have their values transferred to the same table.

I am unsure how to do this, but I do know I should use DAO, which I am not very good with. I did come across this code and attempted to use it:

dim rs2 as dao.recordset

set rs2 = currentdb.openrecordset("tbl_Name") 'name of table you want to append records to

rs1.movefirst
while not rs1.eof
rs2.addnew
rs2!FieldName = rs1!FieldName 'etc etc for however many fields in recordset
rs2.update
rs1.movenext
wend
rs1.close
rs2.close
set rs1 = nothing
set rs2 = nothing


However, I was unable to get it to do anything in terms of updating the table (although I received no errors from my form). I placed it in the event for AfterUpdate for my date field. Essentially, a person must select a date to produce any calculations.

I believe part of my problem may be from the use of subforms, but since I am not that familiar with DAO, I am unsure.

Any help is much appreciated!
 

Users who are viewing this thread

Top Bottom