Move to Next Record on Subform

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I am using a command button to copy data from one subform1 to another
subform2. Once the data had been copied to subform2, I'd like to have the
next record in Subform2 ready to accept data.

What happens is if I click the command button in subform1 it copies the data
to the first record in subform2 unless I manually select the next record in
subform2.

Subform1 is a Continuous Form
Subform2 is a Datasheet Form

Both of these subforms are contained in a MainForm.

I hope this make sence.

Private Sub cmdLinkData_Click()
Forms!mainform!subform.Form.fld1 = Me.fld1
Forms!mainform!subform.Form.fld2 = Me.fld2
End Sub

The purpose of this is to link 2 tables into a 3rd table.
We need to link our sales orders to incoming purchase orders. So the planner
clicks a button in the sales order subform and a button in the purchase order
subform and the two are linked in a 3rd table, by the Item#, Order Line#,
Order# --> linked to Item#, PO Line#, Purchase Order#.

Thanks
Matt
 
A

Allen Browne

AddNew to the RecordsetClone of the other subform.

This kind of thing:

Private Sub cmdLinkData_Click()
Dim rs As DAO.Recordset
Set rs = Me.Parent![YourSubformNameHere].Form.RecordsetClone
rs.AddNew
rs!fld1 = Me.fld1
rs!fld2 = Me.fld2
rs.Update
Set rs = nothing
End Sub
 
M

mattc66 via AccessMonster.com

That works to add to a new record. However I have another subform with data I
want to add to the same record in different flds. When I click the button to
add those additional items it places them on the first record on the list not
the new record created by the below suggestion.

What I had hoped, was to click the button in the one subform that would
create the new record and then click the add data button in the other form to
the newly created record from first.

I hope this makes sense. Hard to describe. Basicall, I am trying to create a
table that links data from two seperate tables. Matching a Purchase Order to
a Sales Order requirment.

Matt

Allen said:
AddNew to the RecordsetClone of the other subform.

This kind of thing:

Private Sub cmdLinkData_Click()
Dim rs As DAO.Recordset
Set rs = Me.Parent![YourSubformNameHere].Form.RecordsetClone
rs.AddNew
rs!fld1 = Me.fld1
rs!fld2 = Me.fld2
rs.Update
Set rs = nothing
End Sub
I am using a command button to copy data from one subform1 to another
subform2. Once the data had been copied to subform2, I'd like to have the
[quoted text clipped - 25 lines]
subform and the two are linked in a 3rd table, by the Item#, Order Line#,
Order# --> linked to Item#, PO Line#, Purchase Order#.
 
A

Allen Browne

Didn't really follow that.

If you needed to make the new record the current one, add this after the
Update:
Me.Parent![YourSubformNameHere].Form = rs.LastModifed

Perhaps that will let you copy the stuff from this record to the
recordsetclone in the other subform then, if that's what you need.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

mattc66 via AccessMonster.com said:
That works to add to a new record. However I have another subform with
data I
want to add to the same record in different flds. When I click the button
to
add those additional items it places them on the first record on the list
not
the new record created by the below suggestion.

What I had hoped, was to click the button in the one subform that would
create the new record and then click the add data button in the other form
to
the newly created record from first.

I hope this makes sense. Hard to describe. Basicall, I am trying to create
a
table that links data from two seperate tables. Matching a Purchase Order
to
a Sales Order requirment.

Matt

Allen said:
AddNew to the RecordsetClone of the other subform.

This kind of thing:

Private Sub cmdLinkData_Click()
Dim rs As DAO.Recordset
Set rs = Me.Parent![YourSubformNameHere].Form.RecordsetClone
rs.AddNew
rs!fld1 = Me.fld1
rs!fld2 = Me.fld2
rs.Update
Set rs = nothing
End Sub
I am using a command button to copy data from one subform1 to another
subform2. Once the data had been copied to subform2, I'd like to have
the
[quoted text clipped - 25 lines]
subform and the two are linked in a 3rd table, by the Item#, Order
Line#,
Order# --> linked to Item#, PO Line#, Purchase Order#.
 

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