View Full Version : Add a new record in a subform programmatically


AlineVincent
06-01-2001, 02:07 AM
I have a form with a subform on it and a button. If i press the button, i want a new record being added in the subform automatically.
I tried several things (invane):
1. using a recordset on the table of the subform, is impossible because i have a form open on this table
2. I tried to use recordsetclone but i understood that this is a static copy of the records in the subform and you can't use it to add another record.
3. I tried to use setfocus eg forms!mainform!subform.form![field].setfocus and docmd.gotorecord,,aclastrecord. But without success.
4. I tried to use a recordsetclone and then to bookmark the subform to the recordsetclone.bookmark in order to put the focus on a record in the subform, but nothing happens.

Does anyone has an idea? This task doesn't seem very complicated to me, but it's driving me mad in realizing it.
Thanks

charityg
06-01-2001, 07:13 AM
Did you try:

DoCmd.GoToRecord , , acNewRec

AlineVincent
06-02-2001, 02:10 AM
Thanks for your hint, charityg.
With :
Docmd.gotocontrol (subform)
Docmd.gotorecord,,acNewRec
everything works fine !
Without the first line, a new record is added in the main form.