How to get price in two ways?

M

Mark Anders

Hi all!
I am building a subform for order details and pricing with Acces 2003. There
are unit prices and prices based on square meter in the product table. How
can I get the price both ways into the price field in the subform? The square
meter calculation works very well. Either one of them retrieves the price,
but no both simultaneously.
 
C

Carl Rapson

Mark Anders said:
Hi all!
I am building a subform for order details and pricing with Acces 2003.
There
are unit prices and prices based on square meter in the product table. How
can I get the price both ways into the price field in the subform? The
square
meter calculation works very well. Either one of them retrieves the price,
but no both simultaneously.

It's not clear what you're asking for. Are you wanting to display both
prices in a single field or as separate fields? In either case, you'll need
to set up a query that contains the calculations you need, and base the
subform on that query instead of on the product table directly. Queries can
contain calculated fields, and the subform doesn't know where the fields
come from.

Carl Rapson
 
M

Mark Anders

Hi Carl!
Thank you for reply. The idea is to get the unit price directly from the
product table and m2-based price with calculation after entering dimensions
(W * H, there are fields for both dimensions) to the same UnitPrice-field in
the subform. I have tried a calculation field in the query like
IIf(m2>0,1;m2*UnitPrice;UnitPrice) but no result.
 
M

Mark Anders

I did it!
Many days I hit my head at wall, but now it works. Still is one problem, I
should a few cases write price at the same field but writing into it is not
possible. How this problem could be solved?
 
C

Carl Rapson

Again, it's not clear what you're asking. What do you mean, "write the price
at the same field"? Why is writing into it not possible? Can you show us the
code you're trying to use?

Carl Rapson
 
M

Mark Anders

I am sorry, my english is not very good, but I try to explain. The code in
the query is:
Price:IIf([m2Price]>0;[m2Price];[UnitPrice])
and this comes into the subform field (Price). Because it based on
calculation it does not allow to write in the field. I have tried put the
code as defaut value and UnitPrice as control source but the field gives
message #Name?#. As I said, occassionally need to write in the field. The
original question have solved with this code. Writing problem is new one.
Thanks for interest!
 
S

Steve

How about setting up all your product prices based on square meter. For the
products that have a unit price, set W and H both to 1.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
C

Carl Rapson

Instead of putting the IIf statement into the Control Source of the Price
field, put the code into the subform's Current event instead. That way,
whenever the user moves to the record, the Price field will be calculated
and displayed, but the user can still enter a different value.

Carl Rapson

Mark Anders said:
I am sorry, my english is not very good, but I try to explain. The code in
the query is:
Price:IIf([m2Price]>0;[m2Price];[UnitPrice])
and this comes into the subform field (Price). Because it based on
calculation it does not allow to write in the field. I have tried put the
code as defaut value and UnitPrice as control source but the field gives
message #Name?#. As I said, occassionally need to write in the field. The
original question have solved with this code. Writing problem is new one.
Thanks for interest!
--
Have a Nice Day!


"Carl Rapson" kirjoitti:
Again, it's not clear what you're asking. What do you mean, "write the
price
at the same field"? Why is writing into it not possible? Can you show us
the
code you're trying to use?

Carl Rapson
 
M

Marshall Barton

Carl said:
Instead of putting the IIf statement into the Control Source of the Price
field, put the code into the subform's Current event instead. That way,
whenever the user moves to the record, the Price field will be calculated
and displayed, but the user can still enter a different value.


That is not a good idea, Carl. Just navigating to a record
is not sufficient reason to change a value, especially if a
user had set it previously.

I don't really understand what Mark is tring to do here, but
maybe some code in the form's BeforeUpdate event can check
if the value is Null and only then set it.
 

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