Entering data in subforms

I

Ivan Dragomilov

Hi all, I'm fairly new at this and need a little help.

I have a form with a number of fields on it and a button. When I click on
the button, I want to be able to grab a number of field values and enter them
in a brand new record on the subform.

I can get the values via code, but putting them into the subform is proving
difficult, so any suggestions would be really helpful. Sample DB's welcome
too.

Many thanks in advance.
 
O

Ofer

Just open a record source based on sub form table, enter the values directly
to the table and then refresh the sub form.

dim MyDB as databse, MyRec as recordset

set MyDB=codedb()
' Use that if the key is number
set MyRec = mydb.openrecordset("select * from TableName where MyKey = "
me.key) ' Filter by the field you use to link between the form and the
subform

' Use that if the key is string
set MyRec = mydb.openrecordset("select * from TableName where MyKey = '"
me.key & "'") ' Filter by the field you use to link between the form and the
subform

MyRec.addnew
Myrec!Field1=me.Field1
Myrec!Field2=me.Field2
Myrec!Field3=me.Field3
Myrec!Field4=me.Field4
Myrec!Field5=me.Field5
MyRec.update
me.subformname.requery
 
Top