How to add records to a subform from a listbox on a different form

  • Thread starter stonward via AccessMonster.com
  • Start date
S

stonward via AccessMonster.com

Hi Guys,

This is driving me insane.....
Normally one would select products on an orders form from within a subform
that is linked to OrderDetails, this subform being linked via its PK to the
main form based upon Orders (say).

I have way too many products, of too complex a nature to select in this way.
So I have built a search form which shows the results of a search in a
listbox - which includes the products PK. Now, how do i add the selected item
in the listbox to an 'orderDetails' subform? It appears simple - a matter of
referencing a subform - but it's not!

Can anyone see this, or have I finally flipped?

Thanks for your time,

Stonward the Desperate
 
M

Marshall Barton

stonward said:
Normally one would select products on an orders form from within a subform
that is linked to OrderDetails, this subform being linked via its PK to the
main form based upon Orders (say).

I have way too many products, of too complex a nature to select in this way.
So I have built a search form which shows the results of a search in a
listbox - which includes the products PK. Now, how do i add the selected item
in the listbox to an 'orderDetails' subform? It appears simple - a matter of
referencing a subform - but it's not!


Have you tried something like this in the list box's
AfterUpdate event?

With Forms!Orders.detailsubformcontrol.Form.Recordset
.AddNew
!productFK = Me.listbox
.Update
End With

Make sure that the listbox's bound column is the product PK
field.
 
S

stonward via AccessMonster.com

Marshall said:
Normally one would select products on an orders form from within a subform
that is linked to OrderDetails, this subform being linked via its PK to the
[quoted text clipped - 5 lines]
in the listbox to an 'orderDetails' subform? It appears simple - a matter of
referencing a subform - but it's not!

Have you tried something like this in the list box's
AfterUpdate event?

With Forms!Orders.detailsubformcontrol.Form.Recordset
.AddNew
!productFK = Me.listbox
.Update
End With

Make sure that the listbox's bound column is the product PK
field.


No, not quite - I've been trying to open a form, whilst adding the record to
that forms subform - Gonna try your idea now. Thanks for your help - get back
to you asap.
Thanks again,

Stonward
 

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