View Full Version : complicated query help


snowski55
01-23-2002, 02:21 PM
Here's the low-down:

I have one table with all the product information I need (call it MainTable), including a primary key for each product (call it PKEY) and a price (call it PRICE). On another table (Call it TransTable), I enter the transactions that occur. I enter the primary key of the product, and it ensures this key matches a product in the main product table.
My question:
In my transaction table, after I enter the primary key that matches a product in the main product table, how do I also have the price of the same product from the main product table show up by default in the transactions table?
In other words:
I need a query that returns one value and puts it into the [TransTable].PRICE field by default. This query needs to match the cell in the [MainTable].PRICE column with the row matching the [MainTable].PKEY field and the [TransTable].PKEY field.
Thank-you for any help you can give,

-Ben

Pat Hartman
01-23-2002, 04:38 PM
Your other post was too vague to provide an appropriate answer.

Use a combo box with three columns to select the product. Let the wizard build this for you so it will be configured properly. PKEY would be the bound column. The other two columns would be description and price. Then define two more controls on the form. An unbound control to display description (it does NOT need to be stored in the transaction table) and a bound field to store price (it DOES need to be stored). Then in the AfterUpdate event of the combo box put:

Me.txtDescription = Me.YourCombo.Column(1)
Me.txtPrice = Me.YourCombo.Column(2)

The columns of the combobox rowsource are addressed as a zero based array. .Column(1) actually refers to the second column and .Column(2) refers to the third.

snowski55
01-23-2002, 06:06 PM
I believe I got it to work. Thank-you so much, you are a savior of the nerdy sort I guess.
-Ben