nicktheblue
09-27-2001, 02:45 AM
Many thanks to Carol & pcs for replying to my last post - problem solved! Now for my next question...
I have built my database using a similar model to 'Northwind'. I have around 160 records in my 'products' table, and in my order details form I would like to select one record from a combo box which would then automatically fill in the other fields in the form (you know the type of thing - unit cost etc.). I'm sure this has been covered in the forum Ad Infinitum, but please take pity on a desperate fool!
Many thanks in advance,
Nick
Pat Hartman
09-27-2001, 11:22 AM
In the select query used as the rowsource of the combobox, include the product description and the unit price. In the AfterUpdate event of the combobox place code similar to the following:
Me.txtProdDesc = Me.cmbProduct(1)
Me.txtUnitPrice = Me.cmbProduct(2)
Me.txtProdDesc should be an UNBOUND textbox since you should NOT store the description with the order.
Me.txtUnitPrice should b a BOUND textbox since you DO need to store the unit price with the order.
The fields included in a combo's query are handled as a zero based array. The index for the first field is 0 (that should be the product number), the second field is 1 (I've assumed that is the description field), the third is 2 (I've assumed that is the UnitPrice field).
nicktheblue
09-28-2001, 05:57 AM
Thanks for your reply Pat,
still having problems though!
The combo box is called "ProductID", it has 4 rows, the fourth of which is "UnitCost", and I have created a new text box called "UnitCost1", so I have written an after update event procedure that looks like this-
Me.UnitCost1 = Me.ProductID(3)
I just get a Run Time error on selection - I am sure I am doing something stupid and would appreciate the offer of your superior knowledge!
Thanks again,
Nick
jwindon
09-28-2001, 04:02 PM
Try Me.UnitCost1 = ProductID.Column(3)
Not to barge in on Pat. I'm glad to have had his/her advice. By the way Pat, I purchased the Relational Databases for Mere Mortals. Still waiting on its arrival. Should make for improvements in all aspects of my database designs. Thanks again.
Pat Hartman
09-29-2001, 10:17 AM
Thanks for correcting my typo.