A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Question regarding subform



 
 
Thread Tools Display Modes
  #1  
Old December 2nd, 2006, 06:47 PM posted to microsoft.public.access.forms
Dominic
external usenet poster
 
Posts: 2
Default Question regarding subform

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


  #2  
Old December 2nd, 2006, 08:36 PM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default Question regarding subform

On Sat, 2 Dec 2006 13:47:50 -0500, "Dominic"
wrote:

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]
  #3  
Old December 5th, 2006, 12:41 PM posted to microsoft.public.access.forms
Dominic
external usenet poster
 
Posts: 2
Default Question regarding subform

Thanks, that worked perfectly
"John Vinson" wrote in message
...
On Sat, 2 Dec 2006 13:47:50 -0500, "Dominic"
wrote:

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]



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.