VBA, Access: Creating new record from subform


Joined
Feb 11, 2009
Messages
1
Reaction score
0
Hi guys,

I've got a problem with programmatically creating a new record in a subform from a different subform. Currently, the main form (frmMain) alternatively displays either subform 1 (sfrmSubform1) or subform 2 (sfrmSubform2), depending on what the user has selected. This switching is done via:
Forms!frmMain!container_form.SourceObject = "sfrmSubform1"
Where container_form is the name of the container holding either subform 1 or 2.

From subform 1 (i.e.: the VBA code-behind for subform 1), I'm trying to add a new record to subform 2. I've tried:
Forms!frmMain!container_form.SourceObject = "sfrmSubform2"
Forms!frmMain!container_form.Form.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec

But this does not work. The runtime error I get is that sfrmSubform2 is not open.

Does anyone have any ideas how I can solve this?

Thanks,

Simon
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top