Question regarding subform

D

Dominic

I have a form (orders) with a subform (order details). The subform has the
item, quantity, unit price and discount. The item is a combo box via a query
and places the appropriate item in the field, I am trying to pull the unit
price automatically but do not want to do it via a combo box as that may
lead to errors and I've already made the selection. Unit price is currently
set to be a text field control, do I need a different control instead of
this?

Thanks in advance
 
J

John Vinson

I have a form (orders) with a subform (order details). The subform has the
item, quantity, unit price and discount. The item is a combo box via a query
and places the appropriate item in the field, I am trying to pull the unit
price automatically but do not want to do it via a combo box as that may
lead to errors and I've already made the selection. Unit price is currently
set to be a text field control, do I need a different control instead of
this?

Thanks in advance

You can "push" the unit price from the items table into a textbox,
using the combo.

Just include the (current) unit price in the combo's RowSource query,
and set the combo's column count big enough to include it. You can use
the ColumnWidths property of the combo to conceal the price from the
dropdown.

In the combo's AfterUpdate event put code like

Private Sub cboItemID_AfterUpdate()
Me.txtUnitPrice = Me.cboItemID.Column(2)
End Sub

This will copy the price of the selected item from the *third* (it's
zero based) column of the combo into a textbox named txtUnitPrice.

John W. Vinson[MVP]
 
D

Dominic

Thanks, that worked perfectly
John Vinson said:
You can "push" the unit price from the items table into a textbox,
using the combo.

Just include the (current) unit price in the combo's RowSource query,
and set the combo's column count big enough to include it. You can use
the ColumnWidths property of the combo to conceal the price from the
dropdown.

In the combo's AfterUpdate event put code like

Private Sub cboItemID_AfterUpdate()
Me.txtUnitPrice = Me.cboItemID.Column(2)
End Sub

This will copy the price of the selected item from the *third* (it's
zero based) column of the combo into a textbox named txtUnitPrice.

John W. Vinson[MVP]
 

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