Is there a way to add data as a new record in a subform? (1 Viewer)

joner89

Registered User.
Local time
Today, 04:17
Joined
Nov 15, 2010
Messages
30
I have a bombo box that selects product details, once the details are selected a click button transfers the data from one form to another.

The problem i have is that when it transfers the data it keeps copying over the same record. What i need is it to appear as a new record in the subform i am transferring the data to.

Is there a function to do this? Here is my code so far.

Code:
Code:
Private Sub AddtoOrder_Click()
On Error GoTo Err_AddtoOrder_Click
 Me.Parent.F_Order_line_subform.Form.ProductID = Me.ProductID

Exit_AddtoOrder_Click:
    Exit Sub
Err_AddtoOrder_Click:
    MsgBox Err.Description
    Resume Exit_AddtoOrder_Click
    
End Sub

I know you can do 'RunCommand acCmdRecordsGotoNew', i am not sure where to place it. I tried under this line.

Code:
Me.Parent.F_Order_line_subform.Form.ProductID = Me.ProductID

But it just makes the form i am transferrng the data from go to a new record. Any help would be rgeat.

Thanks in advance!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 13:17
Joined
Jan 20, 2009
Messages
12,852
Move the focus to the target form before running the acCmdRecordGoToNew using the SetFocus Method of the target object.

Depends where the code is located. If on the main form:

Me.subformcontrolname.SetFocus
 

joner89

Registered User.
Local time
Today, 04:17
Joined
Nov 15, 2010
Messages
30
Hi Galaxiom,

Thankyou very much it works perfectly now. So glad that was more simple then the last one haha!
 

Users who are viewing this thread

Top Bottom