Add a new record in a subform programmatically (1 Viewer)

A

AlineVincent

Guest
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

Registered User.
Local time
Today, 01:36
Joined
Apr 17, 2001
Messages
634
Did you try:

DoCmd.GoToRecord , , acNewRec
 
A

AlineVincent

Guest
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.
 

Users who are viewing this thread

Top Bottom