Seting subform's RecordSource

mredmond

Registered User.
Local time
Today, 08:38
Joined
Oct 1, 2003
Messages
32
Setting Subform's RecordSource

I have a form with a large unbound subform area. Depending on which button is pushed on the Main form, I load various subforms into the unbound area. Some of these dynamically loaded subforms themselves have subforms.

I want to programatically add a record to the sub-subform. How do I reference the recordset of the sub-subform?

You guys have never let me down. Thanks in advance!
 
Last edited:
You simply add button on your main form and write a procedure for OnClick event to add record (say your subform has recordsource called Products, which can be a query or a table):

Set mydb = CurrentDb
Set myset = mydb.OpenRecordset("Products")

myset.AddNew
myset![field1] = 123
myset![field2] = 456

myset.Update
myset.Close
mydb.Close
Set mydb = Nothing
Set myset = Nothing
Me.Refresh


Make sure your dataset Products is updateable.

Rgds,
giedrius
 
This is actually a simpler solution than I had in mind. It works great. Thanks.
 

Users who are viewing this thread

Back
Top Bottom