View Full Version : Form problem


bhutz
03-21-2001, 10:07 AM
I have a form with the fields weight and price on it.

I want to be able to have something that calculates the price automatically after a weight has been entered using a query or code, and the price is entered into the price field.

The Price is to be selected from a range of value according to the weight, e.g. between 2kg and 4kg is £7.5 and between 4kg and 6kg is £8 and so on.

I have used a query which prompts for the weight and when entered it returns the value but doesn't place it in the price field.

I have tried using a macro to this and i have been able to select the price retrived from the query and it is highlighted but i don't know how to get it from the query to the form.

Pls help me because i am literally goin crazy over this problem

Rich
03-21-2001, 10:19 AM
Base the form on the query the calculation will then be available to view on the form. You shouldn't really store the calculated price in a table.

bhutz
03-21-2001, 10:34 AM
I think i know what u r suggestin but the thing is the table that the query is retriving the price from is not linked to my main three tables.
I have just looked at the dlookup function and got this to work in excel and wondered if i could do a similar thing in access, that way it wouldn't matter if my tables were linked or not.
Sorry to keep asking but nothing is goin right.

Pat Hartman
03-21-2001, 06:07 PM
Price is one of the few types of data that it is appropriate to "duplicate". The reason for this is that the value of a price column is valid only for a point in time. It is normal to store price data in an order since once an order is shipped, you really don't want the value to change even when the unit price from the product table is increased or decreased.

Anyway, the DLookUp() function will do what you need. Put the code in the AfterUpdate event of the weight field.