Data from a list box to a subform

S

Scott Viney

Hi All,

I have a form for my quotation details. On it is a combo box for the brand
name that links to a list box. Select the combo box and it requeries the
list box with only the products for that brand. Perfect!

Also I have a subform that lists all the details for this quotation. I want
the dblclick event for the list box item to add this data to a new record in
the quotation details subform.

This was the easiest way I could figure out how to do this.

Has anyone done this before and how do you code it?

Have a good one,
Scott V
 
S

Scott Viney

Hmm,

I have had a mess around with VBA...but it puts the information in the first
record. How do I tell it to put in a new record

This is beyond me.

Scott V
 
A

ACG via AccessMonster.com

I would imagin that the information in the subform is being stored in a
table. Assuming it is I would either add a record to the table using the
AddNew function in the code or have the double click run an append query to
add the record.
 
S

Scott Viney

ACG,

But how? Ive tried using the dblclick event for the list box item to add
this data to a new record in
the quotation details subform.

I have posted my code for the double click event below.

Can you show me how to get the data to go in a new record?

Also if I position the record selector in the subform manually at the new
record position and double click an item I get the following ´Runtime Error
´31654´ Field cannot be updated´ It stops at the 'Product Sapiens Code'
lines. If I do the same on an existing record everything works fine.

Any help would be appreciated,
Scott V

Private Sub lstProductos_DblClick(Cancel As Integer)

With Me

'Product ID

sfrmQuotationDetails.Controls.Item("txtProductID") =
..lstProductos.Column(0)

'Product Brand Name

sfrmQuotationDetails.Controls.Item("txtBrandName") =
..cboBrandID.Column(1)

'Product Sapiens Code

sfrmQuotationDetails.Controls.Item("txtProductSapiensCode") =
..lstProductos.Column(1)

'Product Brand Code

sfrmQuotationDetails.Controls.Item("txtProductBrandCode") =
..lstProductos.Column(2)

'Product Description

sfrmQuotationDetails.Controls.Item("txtProductDescription") =
..lstProductos.Column(3)

'Product Presentation

sfrmQuotationDetails.Controls.Item("txtPresentationType") =
..lstProductos.Column(4)

'Product Size

sfrmQuotationDetails.Controls.Item("txtProductSize") =
..lstProductos.Column(5)

'Product Has IVA

sfrmQuotationDetails.Controls.Item("chkProductHasIVA") =
..lstProductos.Column(6)

'Product VR Unit Price

sfrmQuotationDetails.Controls.Item("txtQuotationProductVRUnit") =
..lstProductos.Column(7)

'Product IVA

sfrmQuotationDetails.Controls.Item("txtQuotationProductIVA") =
..lstProductos.Column(8)

End With

End Sub
 
Top