Adding & deleting records on a subform – conflicting info?

J

John F

I am trying to do something that I am sure is very common, specifically
having buttons on the parent form to add and delete a single record on a
subform. I did a search and found suggestions along these lines (including
some variations I tried):

DoCmd.GoToRecord , "Forms!frmParent![fsubSubform].Form", acNewRec

DoCmd.GoToRecord , "Form!frmParent.fsubSubform", acNewRec

DoCmd.GoToRecord , "Me.fsubSubform", acNewRec

DoCmd.GoToRecord , "fsubSubform", acNewRec

The message I received was fsubSubform not open. So I tried
DoCmd.OpenForm "fsubSubform", , , , acFormAdd which was no good because
opened the subform in a separate window.

So I searched again and found someone who received the same message subform
not open. The advice given was to implement a Recordset instead.

Specific questions:

1. Were the suggestions inconsistent, and is implementing a Recordset the
only way to add and delete records on a subform?

2. The suggestion to use a Recordset specifically suggested a recordset
clone. Do I really need a clone? I don’t think I need separate record
pointers.

3. After updating recordset is a requery or something else needed so that
the subform will immediately reflect the added or deleted form?

4. Is there some source of a simple example to show adding and deleting a
single record via an ADO recordset?

Thanks,

John
 
J

Jeff L

1. Were the suggestions inconsistent, and is implementing a Recordset
the only way to add and delete records on a subform?

No, you can add a record by typing in the data, create a query and run
it, or write some SQL in your code and execute it.

2. The suggestion to use a Recordset specifically suggested a
recordset clone. Do I really need a clone? I don't think I need
separate record pointers.

You don't necessarily need to do it that way.

3. After updating recordset is a requery or something else needed so
that the subform will immediately reflect the added or deleted form?

It depends on where you are wanting to requery your subform from. Use
Me.Requery if you are doing a requery from the subform itself. Use
Me.SubformName.Requery if you are doing a requery from the Main Form.
Finally, use
Forms!MainFormName!SubformName.Form.Requery when doing a requery from
outside the Main Form, like in a module or from another form.
 
J

John F

Thanks for the reply. Specifically, is there any way I can get the following
to work. Currently I get a message "fsubSubform not open" In fact, the
records in the subform are visible when the parent form is open.

DoCmd.GoToRecord , "Me.fsubSubform", acNewRec
 

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